Currently Being Moderated

Batch Change Title to Text w/Padded Sequential No.

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:

Automator001.jpg

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

Photos001.jpg

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

Photos002.jpg

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:

Photos003.jpg

 

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

Safari001.jpg

 

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

AppleScript Editor001.jpg

 

A copy of the app can be downloaded with this LINK. 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.

Replies

Delete User Tip

Are you sure you want to delete this user tip?