Hi everyone,
I'm having some trouble with a Bash script that I wrote quite a while ago. I'm running on Debian Wheezy at the moment, the last time I knew this worked was on Lenny probably.
Here's the snippet that I'm having trouble with:
Code:
for i in *.jpg;
do
DIM=`identify $i | cut -d' ' -f3 | cut -dx -f1,2`;
WIDTH=`echo $DIM | cut -dx -f1`;
HEIGHT=`echo $DIM | cut -dx -f2`;
if [ $HEIGHT -gt $WIDTH ]; then
mv $i ./tall;
fi
done
Essentially the 'if' is never validating these two and I have no idea why. It previously worked fine, but after upgrading it just doesn't seem to like it. I searched around and found that bash isn't typed so this should be fine as well.
What I'm cutting out for the parameters is the filesize. Echoing them reveals that it's correctly picking it up e.g. 1900x1200 - though, again, the comparison is always false. If anyone can provide some insight here, I'd be extremely grateful.
If anyone cares, the script itself was written to resize a bunch of images. It runs through and looks at whether it's landscape or portrait and then moves the image to a new directory if so. Eventually it will come back and resize based on what directory the files are in. I'd love to just rewrite it, but the script is huge and this portion is the only piece that doesn't seem to work correctly anymore.
Thanks for any thoughts!