list graphics only for a IFS loop
I've got a script processing a timelapse stills that I'm again trying to improve and ran into a question I can't figure out with google. How do I modify this IFS loop so I list only graphic files, say case insensitive extensions of jpg, gif, png, and maybe bmp? Most of the time I'm sure i'll be dealing with Jpegs only, but I'd rather not limit it?.
Code:
IFS=' Rich |
What do you actually want to do? Seems really quite odd what you're already doing, why are you using a numerical for loop when you can just loop through the array elements anyway? Quite probably easiest to just pass the ls output direct to xargs or a while loop, really.
find . -iname *.jpg -o -iname *.bmp ... -print | while read FILENAME do <stuff> done |
You could simply grep for each file extension you want:
Code:
IFS=' Code:
IFS=' |
I'm using a numerical loop so I can display the progress via Zenity. Eventually I'd like to bring the whole process into a gui interface that is easier for others to use, but this is an incremental process and I keep running into errors on the processing when imagemagick tries to work on thumbnail.db, or a sub-directory, or etc.
Can I use Code:
find . -iname *.jpg -o -iname *.bmp -o -iname *.png -o -iname *.gif -o -iname *.jpeg -print | while read FILENAME Code:
/bin/ls -1 --ignore=resized_to_* Also the full script is below for context. Thanks, Rich Code:
|
Thanks osor, the magic version is exactly what I'm looking for however, I seems to be missing something. When I put either version of the if-then-if grep test into the loop it doesn't return any values. (Below is the bash -x result for the intial part of the loop using the extension grep.)
Code:
$ bash -x ~/guiconvert720x480.sh Code:
ls -1 | grep -qiE '\.(jpg|png|gif|svg|bmp)$' Thanks, Rich |
Quote:
Code:
IFS=' Code:
( IFS=' Code:
( IFS=' Code:
( ls -1 --ignore=resized_to_* | grep -iE '\.(jpg|png|gif|svg|bmp)$' | while read file Quote:
Code:
$ echo "foo.jpg" | grep -qiE '\.(jpg|png|gif|svg|bmp)$' |
All times are GMT -5. The time now is 12:28 AM. |