#!/bin/bash DEST=/var/www/Pix/new/KEEP/FRAME/out mkdir -p "$DEST" "$DEST"/badfiles "$DEST"/bigfiles "$DEST"/dupefiles touch $DEST/.marker echo "restoring dupe files if any" mv "$DEST"/dupefiles/* "$DEST" for dir in /var/www/Pix/albums /var/www/PrivPix/albums ~merlin/public_html/perso/companies/Pix/albums/ ~merlin/public_html/linux/photos/albums/ do cd $dir echo "Running find in $dir" for i in `find | grep BestOf | grep jpg` do dest=`echo "$i" | sed -e "s#^./##" -e "s#BestOf/##" -e "s#/#!#g" -e "s#[ '\"]#_#g"` if [ -f "$DEST/$dest" ]; then echo "skipping existing $dest" else echo "copying $i -> $dest" cp "$i" "$DEST/$dest" fi done done cd "$DEST" || exit 1 echo "removing dupes" # finddupes skips empty files finddupes . | grep Dupe | sed "s/Dupe is //" | xargs -r truncate -s0 find -maxdepth 1 -size 0 -print | while read file do mv -v "$file" dupefiles done mv dupefiles/.marker . echo "removing non jpeg" file *.jpg | grep -v JPEG | sed "s/:.*//" | while read file do mv $file badfiles done echo "resizing pictures" find . -type f -name \*.jpg -newer $DEST/.marker | sort | while read i do echo "$i" mogrify -quality 80 -verbose -scale 1280x1024 "$i" done echo "removing dupes after resize" finddupes . | grep Dupe | sed "s/Dupe is //" | xargs -r truncate -s0 find -maxdepth 1 -size 0 -print | while read file do mv -v "$file" dupefiles done echo "moving out big or bad files" identify *.jpg | grep -Ev '(1280x|x1024)' | sed "s/\.jpg.*/.jpg/" | while read file do mv -v "$file" bigfiles done #cd $DEST #ls | while read file #do # touch "$file" # sleep 1 # echo "done with $file" #done