Sample Header Ad - 728x90

Terminate script using zenity progress bar

2 votes
1 answer
2619 views
(GNOME2, Ubuntu 10.04 LTS) I've made a nautilus script, so that if I have a directory full of various codecs, then I just need to right click in that folder -> Scripts -> THISSCRIPT.txt, then presto, it recursively converts all the video files (identified by video mimetype) to x.264 codec with 128 Kbit mp3 to avi. So that they will have small size+good quality. This works, great! **QUESTION**: If I press "Cancel" on the Zenity progress bar, then the mencoder doesn't terminates.. How can I do this? I mean I need that If I press "Cancel" on the Zenity progress bar, it would terminate mencoder. How to do this? #!/bin/bash which mencoder > /dev/null 2>&1; if [[ $? -ne 0 ]]; then echo -e '\nerror, no mencoder package detected'; exit 1; fi which zenity > /dev/null 2>&1; if [[ $? -ne 0 ]]; then echo -e '\nerror, no zenity package detected'; exit 1; fi HOWMANYLEFT=0 find . -type f | xargs -I {} file --mime-type {} | fgrep "video/" | rev | awk 'BEGIN {FS="/oediv :"} { print $NF}' | rev | while read ONELINE do if file "$ONELINE" | egrep -qvi "x.264|h.264" then echo $ONELINE fi done | sed 's/^.\///' | tee /tmp/vid-conv-tmp.txt | while read ONELINE do HOWMANY=wc -l /tmp/vid-conv-tmp.txt | cut -d " " -f1 mencoder "$ONELINE" -o "OK-$ONELINE.avi" -ovc x264 -x264encopts bitrate=750 nr=2000 -oac mp3lame -lameopts cbr:br=128 > /dev/null 2>&1 HOWMANYLEFT=expr $HOWMANYLEFT + 1 echo "scale=10;($HOWMANYLEFT / $HOWMANY) * 100" | bc | cut -d "." -f1 done | zenity --progress --text="Processing files ..." --auto-close --percentage=0
Asked by gasko peter (5634 rep)
Jul 1, 2012, 11:17 PM
Last activity: Jul 2, 2012, 01:24 PM