Terminal: command line to match same base but different extensions?

Joined
Jan 1, 2012
Messages
1
Reaction score
0
Points
1
Hi - apologies if this is a FAQ but...

..I have been converting some movies to both .mp4 (using a hardware encoder) and m4v (using Handbrake). The .m4v files are found to be superior and I need to find those movies for which I have both types. There's a lot to find on many drives attached to my MBP.

So for example, under my user account ~/. I have e.g. a source movie aa.avi which I have converted to aa.mp4 and aa.m4v, the same for e.g. bb.avi etc etc etc. and loads more movie files.

I want to use a command line search to identify all files with the same prefix for which I have both the mp4 and m4v versions and then to move that m4v to a fixed directory of my choice (and ideally the mp4 to another fixed directory). The result will leave any standalone mp4's without m4vs where they are since they will be from other sources, not ones I have necessarily converted.

I got as far as this.

find ~ -name '*.mp4' -exec basename {} \; | cut -d . -f1


but then a) couldn't append ".m4v" to the result with a view to
b) feeding it into a second | find ~ -name where the combined string was the new search and then
c) using that result to feed into an mv command to send the m4v file to a specific directory
d) somehow using the result again to an mv command to send the mp4 file to another specific directory

All help gratefully received. I appreciate it is a kludgy and probably horribly slow way to do it, all ways to improve v much appreciated. Shell scripts equally welcomed.

thanks

Richard
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top