Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Batch Change Title to Text w/Padded Sequential No.

Last modified: Jul 1, 2018 10:38 AM
6 9487 Last modified Jul 1, 2018 10:38 AM

This Automator/Applescript workflow will batch change the titles on selected images in the Photos library to user specified text followed by a sequential number padded with zeros .


The script, thanks to léonie with a couple of minor changes by me, is:

on run {input, parameters}


-- batch change the title to the input, © léonie & Old Toad, version 1.0.1


-- return 1

set n_digits to 2 -- how many digits for the appended number

set answer to display dialog "Select the number of digits for the appended numbers (0 .. 10). Selecting '0' will suppress the leading zeros." buttons {"o.k"} default answer n_digits



-- For 1-9 photos use 2. For 10 to 99 photos use 3 and use 4 for 100 or more photos.


set n_digits_text to the (text returned of answer)

set n_digits to n_digits_text as number


tell application "Photos"

activate

set counter to 1

set imageSel to (get selection) -- get selected images

if imageSel is {} then

error "Please select some images."

else

repeat with im in imageSel

set ntext to the counter as text

repeat while (the length of ntext < n_digits) -- add leading zeros

set ntext to "0" & ntext

end repeat


tell im

set the name to input & "-" & ntext as text

-- set the title to the input plus formatted number

set counter to counter + 1

end tell

end repeat

end if

end tell

return "Done. The titles of " & (length of imageSel) & " photos have been changed."

end run

The Automator workflow looks like this:

User uploaded file

You can save the workflow as a service or as an application. When run the first window is

User uploaded file

where you put in the common title for all images selected. The next window,

User uploaded file

sets the number of digits for the following sequential no. I use 2 for 1-0 images, 3 for 10 - 99 images and 4 for 100 or more images. The result is this:

User uploaded file


I prefer to save as an application and put the app in the Scripts Folder so it is easily available from any window:

User uploaded file


The Script menu is activated via the Applescript Editor/General preference pane

User uploaded file


A copy of the app can be downloaded from P01 - Applescripts from Photos’ User Tips Compiled as Applications.

To run it for the first time Control (right) - click on it and select Open from the contextual menu. If you build it yourself this won't be necessary.


Again, thanks to léonie for most of the input for this app.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.