I wrote an AppleScript that takes a bunch of scanned jpegs with systematically named filenames and transfers information from the filename into the date and time fields. That all works fine, but I've got many more scans to do and I'd like to augment the script to include a progress meter because it takes a long time to run on e.g. 1000 photos. I've found basic progress meter examples online that involves commands like:
set progress total steps to theImageCount
set progress completed steps to 0
set progress description to "Processing Images..."
set progress additional description to "Preparing to process."
and they run OK in a separate dummy test case, however I'm getting syntax errors for such commands in my renaming script because (I think) they're inside a
tell application "Photos"
wrapper and it looks like Photos doesn't like those commands.
A progress meter (in any AppleScript) should be a straightforward thing i.e. I can clearly define a total number of steps and I can clearly define the step number I'm currently on. I just want to display something like:
I'd even be OK with just implementing something like:
display dialog "blah blah"
but that needs to be manually dismissed with each iteration of the loop, so that's no good. I also tried:
display notification "blah blah"
but that yields hundreds of notification boxes at the top right of my screen, so that's also impractical.
I was even thinking maybe I could call some generic system progress meter with all the right variables via a "do shell script" command (although I have no idea how to do that). Something surely must be possible, but I just can't figure it out :-(. Could some kind soul please help me out. Thanks.
Thanks for asking. I think you're on the right track using the "set progress" commands. For a complete list, they are documented here:
Mac Automation Scripting Guide: Displaying Progress
If you're finding there is a conflict with the scripting provided by an app and the 'progress' commands then you can take the progress commands out of the tell blocks by doing a little re-formatting like the following:
set progress description to "processing photos" set progress additional description to "starting task" tell application "..." -- commands for the first part of your task... end tell -- perform three steps x, y, and z set progress additional description to "performing step x" set progress total steps to 3 set progress completed steps to 0 tell application "..." -- steps for x end tell set progress completed steps to 1 set progress additional description to "performing step y" tell application "..." -- steps for y end tell set progress completed steps to 2 set progress additional description to "performing step z" tell application "..." -- steps for z end tell set progress completed steps to 3 -- display some indication that the task is complete set progress additional description to "processing complete" beep 1