Why is this bash script read line code giving me errors?

read -p "Does this require cropping? (y/n)? " answer
case ${answer:0:1} in
    y|Y )
mkdir cropped; for i in *.mp4; do ffmpeg -i "$i" -filter:v "crop=1900:1080:-20:0" cropped/"${i%.*}.mp4"; rm -r *.mp4; cd cropped; cp -r *.mp4 ../
    * )
mkdir no

When I give an answer, I get this back from terminal:

Does this require cropping? (y/n)? n
/usr/local/bin/prep: line 17: syntax error near unexpected token `;;'
/usr/local/bin/prep: line 17: `    ;;'

However, it works perfectly fine if my executed (YES) answer code is changed something like, rather than the whole mkdir cropped; for i in *.mp4...:

mkdir yes

closed as off-topic by Michael Homer, Kusalananda May 26 at 6:51

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Michael Homer, Kusalananda
If this question can be reworded to fit the rules in the help center, please edit the question.


You are missing the done on your for loop, so the no ) and stuff is part of the loop.

  • Ohhhh.. you mean after *.mp4 ../ so it should be *.mp4 ../ done ? – Anonymous May 26 at 4:15
  • seems to be missing ; done ... got it, thanks! – Anonymous May 26 at 4:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.