From 6a75f0aa714363398daef6c912ca8871d04fffc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20A=2E=20Ortega?= Date: Sat, 23 Apr 2016 14:07:45 +0200 Subject: [PATCH] Ask if the user wants to confirm all files. Pressing `y' on all those files might be annoying. --- ogg-converter.sh | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/ogg-converter.sh b/ogg-converter.sh index 93185d1..4a3c52c 100755 --- a/ogg-converter.sh +++ b/ogg-converter.sh @@ -2,21 +2,40 @@ # Copyright (c) 2016 Nicolás A. Ortega # License: GNU GPLv3 +while true +do + read -p "Should Ogg-Converter confirm each conversion? (y/n)" ANSWER + case $ANSWER in + [yY]* ) CONFIRMATION=true + break;; + + [nN]* ) CONFIRMATION=false + break;; + + * ) echo "Please enter a valid option." + esac +done + for f in $@ do OUTFILE=${f:0:-4} echo "Convert $f to $OUTFILE.ogg" - while true - do - read -p "Do you wish to continue? (y/n) " ANSWER - case $ANSWER in - [yY]* ) ffmpeg -loglevel warning -i $f $OUTFILE.ogg - break;; + if $CONFIRMATION + then + while true + do + read -p "Do you wish to continue? (y/n) " ANSWER + case $ANSWER in + [yY]* ) ffmpeg -loglevel warning -i $f $OUTFILE.ogg + break;; - [nN]* ) echo "Skipped file $f" - break;; + [nN]* ) echo "Skipped file $f" + break;; - * ) echo "Please enter a valid option." - esac - done + * ) echo "Please enter a valid option." + esac + done + else + ffmpeg -loglevel warning -i $f $OUTFILE.ogg + fi done