Article 4TVJX Delete source after ffmpeg converts to target

Delete source after ffmpeg converts to target

by
ericlindellnyc
from LinuxQuestions.org on (#4TVJX)
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.latest?d=yIl2AUoC8zA latest?i=GzlMTtjAP0Q:0TmKjdSrcTM:F7zBnMy latest?i=GzlMTtjAP0Q:0TmKjdSrcTM:V_sGLiP latest?d=qj6IDK7rITs latest?i=GzlMTtjAP0Q:0TmKjdSrcTM:gIN9vFwGzlMTtjAP0Q
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments