Delete source after ffmpeg converts to target
Code:
find . -type f -name '*.wav' -exec bash -c 'ffmpeg -n -i "$0" -c:a libmp3lame -q:a 2 "${0/%wav/mp3}"' '{}' \; 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"' ‘{}’ \; 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. |
you should only delete the source if ffmpeg completed without error
find is good at finding things and sure, you can get it to execute things, but it is not really the best approach this is a little bash script Code:
#!/bin/bash Code:
wavtomp3.sh /path/to/dir/withwavs if the ffmpeg completes without error the .wav is deleted if there was an error it exits printing filename to stderr https://mywiki.wooledge.org/BashGuide http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-3.html or you could create a file ~/.bash_functions Code:
wavtomp3 () { and Code:
. ~/.bash_functions /!\ note the . at the start then Code:
wavtomp3 /path/to/filename.wav |
Nice post, good advice.
|
Quote:
Along with my added:
Keep enough space. Keep the newly converted stuff in a new directory. Verify it first, and then delete your originals. |
ericlindellnyc, are you now using some kind of Linux?
One of your last threads, took us like 20 posts to find out you run iOS... |
All times are GMT -5. The time now is 07:17 PM. |