From 2bb4aacc7678b60982d166eefc459c088476a713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Tue, 31 Mar 2015 13:59:17 +0000 Subject: [PATCH] better tests --- src/convert-videos.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/convert-videos.sh b/src/convert-videos.sh index 24623ff..e7d1915 100755 --- a/src/convert-videos.sh +++ b/src/convert-videos.sh @@ -11,19 +11,18 @@ FLAGS["mp4"]="-vcodec libx264 -acodec aac -strict experimental -crf 19" for f in $(find "$SRC" \( \( -name '.??*' -o -name '*.jpg' \) -prune \) -o -type f -print); do for format in ${FORMATS}; do - t="${f/$SRC/$DST/${format}}" t="${t%.*}.${f}" if test -s "${t}"; then - continue; + continue; # ignore if file exists and is not empty fi - if ( ! test -s "${t}" ) && ( test -e "$t" ); then - rm "$t" + if test -e "$t"; then + rm "$t"; # remove existing empty file fi test -d "${t%/*}" || mkdir -p "${t%/*}" - avconv -i "$f" ${FLAGS[$f]} -filter:v yadif "$t" - if ( ! test -s "${t}" ) && ( test -e "$t" ); then - rm "$t" + if ( ! avconv -i "$f" ${FLAGS[$f]} -filter:v yadif "$t" + || ! test -s "${t}") && test -e "$t"; then + rm "$t"; # remove file if conversion failed fi done done