I want to compress my entire music collection (a copy of it, actually) using lame. So naturally, there are folders within folders and possible weird characters in file names. I used the graphical soundconverter as well, but didn't like it as it has predefined bit rates.
What I've tried so far:
$ find . -name "*.mp3" | lame -b 160and
$ find . -name "*.mp3" > list
$ cat list | lame -b 160and
$ lame -b 160 < listAll of these give me usage error. What is the right way to do it? Also, if there's a way to overwrite the original file, I'll be too happy.
12 Answers
lame cannot read in filenames from input. You will have to use find's -exec or xargs to run it over each file found:
find . -iname '*.mp3' -exec lame -b {} \;If a second filename isn't specified, lame will attach another .mp3 to the given filename and write to that file. lame does not support writing to the same file. You'll have to convert to another file, then copy it over the original file:
find . -iname '*.mp3' -exec sh -c 'lame -b 160 "$0" "$0"-160 && mv "$0"-160 "$0"' {} \; 1 Try a the following:
Start with removing whitespaces from the file names since these seems to cause trouble:
for f in $(find . -name "*.mp3"); do rename "s/\s+/_/g" *; doneExecute a loop and traverse through all files:
for f in $(find . -name "*.mp3"); do lame -b 160 "$f" tmp && mv tmp "$f"; doneNow you will overwrite the original files with those created by lame.
11