For those of you who are unaware of what
jpegtran is, I suggest you press the link and read the Wikipedia article.
To install jpegtran, I used the following on Debian / Ubuntu:
Code:
# apt-get install libjpeg-progs
Remember, in order to execute the shell script, the file permissions should be altered:
Code:
# chmod a+x jpegtran_recursion.sh
The following is a code I have been writing to try to recursively rotate an entire directory of portrait images. Here are the details:
Files to be rotated are moved in a directory ROTATE
All final files are written to the parent directory of ROTATE
File names are in the format DSC#####.JPG (no .jpg or .JPEG)
File names are only 12 characters long
Here's the code. I've named it Rjpegtran.sh:
Code:
#!/bin/sh
numero=0
picls=$(ls -1 /home/kp/Pictures/ROTATE)
while [ $numero -lt 257 ]; do
picname=$(echo ${picls:$numero:12})
`jpegtran -rotate 270 -outfile /home/kp/Pictures/$picname /home/kp/Pictures/ROTATE/$picname`
numero=$(expr $numero + 13)
done
Now, unfortunately, I keep getting the following error from bash:
Quote:
Empty input file
./jpegtran_recursion.sh: 9: Bad substitution
If anybody could provide insight on why bash is angry, then this shell script might be of some use!