diff --git a/draw.sh b/draw.sh index 2a53ab9..aa94915 100644 --- a/draw.sh +++ b/draw.sh @@ -1,5 +1,16 @@ #!/bin/bash +askContinue () { + echo "Are you ready to continue? (yes/no)" + read input + if [ "$input" != "n" ] && [ "$input" != "no" ] + then + echo "${1}" + else + exit 1 + fi +} + if [[ "${1}" == "" ]]; then echo "Please provide a directory as the first argument" exit 1 @@ -15,14 +26,19 @@ if [ "${2}" == "" ]; then rm -f "${number}" bash position.sh reset - echo "Are you ready to continue? (yes/no)" - read input - if [ "$input" != "n" ] && [ "$input" != "no" ] - then - echo "Starting with first frame..." - else - exit 1 - fi + askContinue "Starting with first frame..." +else + c=0 + for svg in "${1}"*.svg ; do + if [ "${c}" != "${2}" ]; then + let "c=c+1" + continue + fi + filename=`basename "${svg}"` + echo "Starting frame: ${filename}" + break + done + askContinue "Continuing with frame ${filename}..." fi i=0 @@ -44,13 +60,7 @@ for svg in "${1}"*.svg ; do ax "${svg}" rm -f "${number}" bash position.sh reset - echo "Are you ready to continue? (yes/no)" - read input - if [ "$input" != "n" ] && [ "$input" != "no" ] - then - echo "Continuing with next frame..." - else - break - fi + + askContinue "Continuing with next frame..." done