ubuntu: sudo apt-get install lame ffmpeg libavcodec-extra-53Then cd to the directory with flac files and use find (or change ffmpeg for avconv):
find -name "*.flac" -exec ffmpeg -i {} -acodec libmp3lame -ab 128k {}.mp3 \;
Done! You now have the exact same filenames with .mp3 encoding (also adds .mp3 at the end but keeps the .flac as well).
Enjoy.
Notes:
- Obviously, change *.flac to whatever extension your input files are in
- You can also change the output codec by replacing libmp3lame to whatever codec you'd like
- Heck, just use man find ;)
- If you don't like the .flac.mp3 thing, you can rename easily (I like it since it tells me it came from a lossless source, which is likely sitting somewhere on my hard drive):
rename 's/\.flac//' *.mp3
Alternative without ffmpeg
If you don't have ffmpeg and prefer using lame and flac directly, first install the codecs if you dont have them already.Ubuntu: sudo apt-get install flac lame
Arch: sudo pacman -Syu flac lameThen, convert away!
find . -name '*.flac' -exec sh -c 'flac -cd "{}" | lame - "{}".mp3' \;
You can also do this in the current folder only with a for-loop:for f in *.flac; do flac -cd "${f}" | lame - "${f}.mp3"; done;
Set the target bitrate depending on the quality/size you prefer with the -b option of lame: lame -b 320 - "${f}.mp3"