I succeeded to turn up the volume of the sound on mp3 files recursively. First in my music directory I did
ls > ls.txt
Then I use this script :
while IFS= read -r line; do
find /your/directory/path/"$LINE" -type f -iname '*.mp3' -exec lame --scale 2 {} \; -exec mv {}".mp3" {} \;
done < ls.txt
Lame add.mp3 to each transformed-file name so I replace the original by the new while keeping the same file name. Do you know a more elegant code? Thank you
Your code breaks if there is a filename with a newline character in it. This is pretty rare, and you may ignore it.
Other, more serious problems:
Further, you are storing each line in the file
ls.txtinto the variableline, but you never use this variable, but instead access a variable namedLINE.ls.txtcontains all the entries in the working directory without path component, while yourfindcommand searches those entries in the directory/your/directory/path/. Therefore you either omit the path component (assuming that you are in the "right" directory anyway), or that you generate the file list using absolute directories.Actually, unless you need the file
ls.txtagain in a different place, I would not even bother creating it, but instead just writeAnother possibility would be to get rid of the
findcommand altogether and do aThe disadvantage of this solution is that it could fail, if the directory tree contains a such large number of matching files, that the expanded glob pattern would overflow the command line limit for bash. This size is not defined by bash itself, but depends on the operating system. You can get this size by doing a
getconf ARG_MAXand then decide whether or not this could be a problem for you.