Bash script to convert all *flac to *.mp3 with FFmpeg?

A simple 1 liner solution: find -name "*.flac" -exec ffmpeg -i {} -acodec libmp3lame -ab 128k {}.mp3 \;

http://lewisdiamond.blogspot.ca/2012/01/converting-flac-to-mp3.html

Note that this will be applied recursively in the given directory. I.e. if you run this from your Music folder, it will convert all flacs from subfolders and produce a .mp3 next to it. You may also do it without ffmpeg by directly using flac and lame (i.e. read w/ flac, pipe to lame, output to a file .mp3), as shown in the link.


Try this:

for i in *.flac ; do 
    ffmpeg -i "$i" -acodec libmp3lame "$(basename "${i/.flac}")".mp3
    sleep 60
done

If you have some white spaces in the file names:

for a in *.flac; do
  f="${a[@]/%flac/mp3}"
  ffmpeg -i "$a" -qscale:a 0 "$f"
done