Code:
find . -type f -name '*.wav' -exec bash -c 'ffmpeg -n -i "$0" -c:a libmp3lame -q:a 2 "${0/%wav/mp3}"' '{}' \;
I used the above code successfully to convert .wav files to .mp3 files using ffmpeg.
However, my drive fills up fast, and I tried incorporating a command to rm the wav file after convert, like this ..
Code:
find . -type f -name '*.wav' -exec bash -c 'ffmpeg -n -i "$0" -c:a libmp3lame -q:a 2 "${0/%wav/mp3}"' '{}' \; -exec bash -c 'rm "$0"' ‘{}’ \;
I tried many permutations of this, removing quotes around $0 (after rm), trying different kinds of quotes -- straight ones, slanting one way or the other -- even apostrophes in place of single quotes.
Results were, just hanging.
system doesn't recognize rm command.
or it doesn't recognize a file name with embedded spaces that's parsed into constituent words by the system.
In the latter two cases, ffmpeg goes to the next file, leaving target MP3s and source WAVs in the directory.
I know find can take multiple execs, & I think there's a way to modify the ffmpeg command to rm the source file.
I can't find anything on this. I think it's a matter of referencing the same variable in both -exec commands.