Is there a way to quickly change all the file extensions of all files in a folder?
Solution 1:
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.
Solution 2:
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:
for file in *.m4b; do mv -- "${file}" "${file/%m4b/m4a}"; done
If you want to see what would be changed by the command, place echo
before mv
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.