Convert all found m4a to mp3
When reading a file line by line, if a command inside the loop also reads stdin, it can exhaust the input file.
Continue reading here: Bash FAQ 89
So the code should look like this:
find . -name '*.m4a' -print0 | while read -d '' -r file; do
ffmpeg -i "$file" -n -acodec libmp3lame -ab 128k "${file%.m4a}.mp3" < /dev/null
done
Why not just use the -exec
argument of find
? So find -iname '*.m4a' -exec ffmpeg -i {} -n -acodec libmp3lame -ab 128k {}.mp3 \;
and run a rename
command afterward?