afconvert with find and exec.

So I'm trying to make a recursive command to find and convert all .mp3 files to .m4a.


This is what I have this far for a few tries:

afconvert -d 'aac ' -f 'm4af' *.mp3 new1.m4v


find . -name "*.mp3" -exec afconvert -d acc -f 'm4af' *.mp3 *.mv4 {} \;



I know *.mv4 may not be the best wildcard to use.


Thanks much


Josh

Mac mini, Other OS, 10.8.3

Posted on Jan 19, 2015 5:16 PM

Reply
4 replies

Jan 20, 2015 6:14 AM in response to JoshFree

Let's talk about your wildcard expansion. In your first attempt -


afconvert -d 'aac ' -f 'm4af' *.mp3 new1.m4v


The shell attempts to expand every file that ends in .mp3 into the arguments of the command. Something like-


afconvert -d 'aac ' -f 'm4af' file1.mp3 file2.mp3 file3.mp3 new1.m4v


According to the sparse manual and overly verbose help option the command accepts one source file and an optional outfile name.


In your second attempt, you are attempting to expand file names within find's exec function. This function is not a shell so wildcards are meaningless.


find . -name "*.mp3" -exec afconvert -d acc -f 'm4af' *.mp3 *.mv4 {} \;


The enclosing parenthesis "{}" contain the file name. You do not need to have a outfile name. afconvert will automatically name the file with the m4a extension. This should work- Of course, Use at Your Own Risk.


find . -name "*.mp3" -exec afconvert -d acc -f 'm4af' {} \;

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

afconvert with find and exec.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.