Created
March 2, 2018 14:09
-
-
Save geekbrit/a9e640bdd42e4f1d5f84997d1ee17127 to your computer and use it in GitHub Desktop.
BASH Daemon to watch for new image files, correct any rotation and resize within max dimensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# create watches for each subfolder within the specified location (1 level deep) | |
# renames the uploaded files to avoid infinite loop | |
# | |
for d in $(find /home/peter/Dropbox/MiniDonkies/Donkeys -maxdepth 1 -type d) | |
do | |
( | |
if [ '/home/peter/Dropbox/MiniDonkies/Donkeys' != $d ]; then | |
echo "$d" | |
inotifywait -m $d -e create -e moved_to | | |
while read path action file; do | |
echo "$path - $action - $file" | |
if [[ $file == *"jpg" ]] || [[ $file == *"JPG" ]]; then | |
mv $path$file "$path$file.JPEG" | |
jhead -autorot "$path$file.JPEG" | |
mogrify -resize 1200x1200 "$path$file.JPEG" | |
fi | |
done | |
fi | |
) & | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment