matching if/else in bash script

I have a bash script that I want to certain actions if it finds a string in the filenames, and another action if it does not match the string in the filename. Both my individual 'for' statements work on their own, however when i put it all together it returns 'unexpected end of file error'. Can anyone tell me what I am doing wrong? Thanks so much.

#!/bin/bash
cd /Users/programmer/UPLOADS/s3-video
for f in $(find . -name "*4x3*" -type f -maxdepth 1);
do
/usr/local/ffmpeg -itsoffset -4 -i "$f" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 404x300 "../s3-thumbnails/${f%.mp4}.1.jpg";
/usr/local/ffmpeg -itsoffset -8 -i "$f" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 404x300 "../s3-thumbnails/${f%.mp4}.2.jpg";
/usr/local/ffmpeg -itsoffset -12 -i "$f" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 404x300 "../s3-thumbnails/${f%.mp4}.3.jpg";
/usr/local/ffmpeg -itsoffset -16 -i "$f" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 404x300 "../s3-thumbnails/${f%.mp4}.4.jpg";

for f in $(find . -not -name "*4x3*" -type f -maxdepth 1);
do
/usr/local/ffmpeg -itsoffset -4 -i "$f" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 540x300 "../s3-thumbnails/${f%.mp4}.1.jpg";
/usr/local/ffmpeg -itsoffset -8 -i "$f" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 540x300 "../s3-thumbnails/${f%.mp4}.2.jpg";
/usr/local/ffmpeg -itsoffset -12 -i "$f" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 540x300 "../s3-thumbnails/${f%.mp4}.3.jpg";
/usr/local/ffmpeg -itsoffset -16 -i "$f" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 540x300 "../s3-thumbnails/${f%.mp4}.4.jpg";
done
#!/bin/bash
cd /Users/programmer/UPLOADS/s3-video
for f in $(find . -name "*4x3*" -type f -maxdepth 1);
do
/usr/local/ffmpeg -itsoffset -4 -i "$f" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 404x300 "../s3-thumbnails/${f%.mp4}.1.jpg";
/usr/local/ffmpeg -itsoffset -8 -i "$f" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 404x300 "../s3-thumbnails/${f%.mp4}.2.jpg";
/usr/local/ffmpeg -itsoffset -12 -i "$f" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 404x300 "../s3-thumbnails/${f%.mp4}.3.jpg";
/usr/local/ffmpeg -itsoffset -16 -i "$f" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 404x300 "../s3-thumbnails/${f%.mp4}.4.jpg";
done
for f in $(find . -not -name "*4x3*" -type f -maxdepth 1);
do
/usr/local/ffmpeg -itsoffset -4 -i "$f" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 540x300 "../s3-thumbnails/${f%.mp4}.1.jpg";
/usr/local/ffmpeg -itsoffset -8 -i "$f" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 540x300 "../s3-thumbnails/${f%.mp4}.2.jpg";
/usr/local/ffmpeg -itsoffset -12 -i "$f" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 540x300 "../s3-thumbnails/${f%.mp4}.3.jpg";
/usr/local/ffmpeg -itsoffset -16 -i "$f" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 540x300 "../s3-thumbnails/${f%.mp4}.4.jpg";
done

for starters try that.

I cannot see how this returns a "string" for you to process. Does each ffmpeg call display something useful?

Also, the find might be returning files with quotes.

Change for lines to:

 
$(find . -name "*4x3*" -type f -maxdepth 1 | sed 's/"/\\"/g;  s/'\''/\\'\''/g');
 
$(find . -not -name "*4x3*" -type f -maxdepth 1 | sed 's/"/\\"/g;  s/'\''/\\'\''/g');

This will scape the quotes.

Thanks a ton, rdrtx1...i am still an extreme newbie...needed the extra done statement. thanks also for the quote escaping, that is a good point, too :slight_smile: