I wrote a script that converts images in a folder. The script uses a for loop:
i="1" for file in *.jpg; do outputFile=$(echo "image"$(echo $i)) convert "$file" -resize 50x50 $outputFile i=$[i+1] done
What I want to do is allow the script to run on multiple file type extensions. Now I've tried doing:
for file in *.jpg *.JPG *.jpeg; do .... done
The problem I have with this is that if you are in a folder with all *.JPG and no *.jpg, the script still bumps i+1 even though there was no images, because it runs the for loop anyways, upon not finding any *.jpg it goes onto *.JPG.
How can I target multiple file extensions without it running itself per type? Example, is their syntax something like this:
for file in [*.jpg | *.JPG]; do ...
That way my output folder always contains images labeled like this:
Instead of ending up with a folder missing image1.jpg because it had no *.jpg to run on first.