I have a large folder of .m4b audio books which in their current format won't play on my Android phone. However they do work fine if they are renamed to .m4a
Is there a quick method or terminal command that can rename every .m4b file in a folder to .m4a? There is no need for any conversion of the files, simply renaming the file extension works perfectly fine.
This will do the job for you.
rename 's/.m4b$/.m4a/' *.m4b
For a test run you can use this command:
rename 's/.m4b$/.m4a/' *.m4b -vn
-v
means "verbose" and it will output the names of the files when it renames them.-n
will do a test run where it won't rename any files, But will show you a list of files that would be renamed.A very quick way to rename files, if that is all you need to do, and do not need to convert them to another format, is to use Bash's parameter expansions, which are detailed very nicely at the Bash wiki.
There are several different ways of changing the extension, but I use here the simple
${var/original/replacement}
paradigm:If you want to see what would be changed by the command, place
echo
beforemv
and the changes will be listed.Needless to say this oneliner could be modified for other files too, and you can also use parameter expansions to remove file extensions too.