You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

32 lines
1.3 KiB

#!/bin/bash
# apt-get install libimage-exiftool-perl jhead jpegoptim
while getopts "r" option; do
case ${option} in
r )
echo "Processing directory recursively"
# move to picture folder and execute script, the directory will be processed recursively
# autorotate images (lossless)
find . -iname \*.jp*g -type f -print0 | xargs -P 3 -0 jhead -autorot
# rename jpg to timestamps
exiftool -ext JPG -fileOrder FileName "-FileName<CreateDate" -overwrite_original -r -d "%Y-%m-%d_%H-%M-%S%%+c.jpg" .
# optimize jpg-files (lossless)
find . -iname \*.jp*g -type f -print0 | xargs -P 3 -0 jpegoptim -o --preserve
exit 0
;;
\? )
echo "invalid option"
exit 1
;;
esac
done
echo "Processing current directory only"
# move to picture folder and execute script, the directory will be processed recursively
# autorotate images (lossless)
find . -maxdepth 1 -iname \*.jp*g -type f -print0 | xargs -P 3 -0 jhead -autorot
# rename jpg to timestamps
exiftool -ext JPG -fileOrder FileName "-FileName<CreateDate" -overwrite_original -d "%Y-%m-%d_%H-%M-%S%%+c.jpg" .
# optimize jpg-files (lossless)
find . -maxdepth 1 -iname \*.jp*g -type f -print0 | xargs -P 3 -0 jpegoptim -o --preserve