From time to time I have some flac files I want to convert to mp3 files so they will play on my car radio. This is simple enough to do,and with a Google search I found this command.
for f in *;do flac -cd $f |lame -b 128 - $f.mp3;done (http://www.upubuntu.com/2011/06/how-to-convert-flac-to-mp3-from-command.html)
The first problem with this is it doesn’t like spaces in the file names. This can be solved by adding quotation marks
for f in *;do flac -cd "$f" |lame -b 128 - "$f".mp3;done
The second problem is, it creates all the files with the name foo.flac.mp3. After a bit of research I found the rename command can quickly rename all of the files.
rename 's/\.flac.mp3$/.mp3/' *.mp3
You could probably add this to the end of the for loop with a && or something