Page 1 of 1

Batch Image Processing with User Input

PostPosted: Sat Aug 22, 2015 9:54 am
by sharkmaul
I'm a professional photographer and I often need images processed and hate throwing them in Photoshop due to the time. I had considered creating folders for common sizes and hard coding the size value into hazel (650px, 700px, 750px, etc.) But that still doesn't work all the time and is a little tedious. I was able to build a shell script that pops up a window and asks for user input but it asks for input on each file, so 100 images requires 100 inputs. Very annoying.

Code: Select all
size="$(osascript -e 'Tell application "System Events" to display dialog "Size?" default answer ""' -e 'text returned of result' 2>/dev/null)"
if [ $? -ne 0 ]; then
    # The user pressed Cancel
    exit 1 # exit with an error status
elif [ -z "$size" ]; then
    # The user left the project name blank
    osascript -e 'Tell application "System Events" to display alert "You must enter a number; cancelling..." as warning'
    exit 1 # exit with an error status
fi

sips -Z $size * "$1"


Any suggestions on typing the number once and once it cycles through every image it's done and resets the input.

Re: Batch Image Processing with User Input

PostPosted: Mon Aug 24, 2015 11:50 am
by Mr_Noodle
What's "every image" in this case? Keep in mind Hazel has no idea what you think a batch is. Files appear in the folder and it can't know what constitutes the start or end of a batch. Depending on that criteria, it can be very difficult to pull off.

One alternative is if you want all the files in a particular folder to constitute a batch in this case, you can instead have Hazel monitor the folder containing that folder. Then you have the rule match the folder and operate on the folder itself. Other than that, though, you'll have to come up with your own system of marking batches and somehow coordinating that with Hazel.