Reputation: 321
I currently have a .command file for Mac that contains the following:
for f in ~/Desktop/Uploads/*.flv
do
/usr/local/bin/ffmpeg -i "$f" -vcodec copy -acodec libfaac -ab 128k -ar 48000 -async 1 "${f%.*}".mp4
rmtrash "$f"
done
How can I tell bash to only execute rmtrash if ffmpeg doesn't produce an error?
Upvotes: 1
Views: 927
Reputation: 785146
Check for return value of ffmpeg command using $?
or put &&
between 2 commands like this:
for f in ~/Desktop/Uploads/*.flv
do
/usr/local/bin/ffmpeg -i "$f" -vcodec copy -acodec libfaac -ab 128k\
-ar 48000 -async 1 "${f%.*}".mp4 && rmtrash "$f"
done
As per the bash manual:
command1 && command2
command2 is executed if, and only if, command1 returns an exit status of zero.
Upvotes: 5