1. imagemagick convert to 1170px over a folder, including subfolder but preserve modified date
2. but doesn't want to process/analyze every image, especially those that are smaller than or equal 1170px
3. skip processed images
4. run script every one hour.
I think for number 2, I google that I would need exiftool but doesn't have experience using it
Here is what I have so far:
crontab -e
Code: Select all
0 * * * * bash sharingan.sh >/dev/null 2>&1
Code: Select all
#!/usr/bin/env bash
find Images -mmin -60 -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.gif' \)|
while read file
do convert -resize 1170 "$file" "$file".tmp
touch -r "$file" "$file".tmp
cp -f -p "$file".tmp "$file"
rm "$file".tmp
done