Script: Batch Change the Descriptions

by: 
Last modified: Jun 19, 2016 2:53 AM
2 6069 Last modified Jun 19, 2016 2:53 AM

Photos 1.1 on Yosemite does not support to change several descriptions at once.

In Photos on El Capitan or newer versions you can simply batch change the description of multiple selected photos at once by opening the Info panel and entering a new description it will applied to all selected photos.

In Photos on Yosemite: To batch change the description of selected photos to the same title you could try a simple Apple Script and run it with Automator.

Create an Automator action, that prompts you for the new title and executes an Apple Script to change the titles to the name you entered:


on run {input, parameters}

-- batch change the description to the input

tell application "Photos"

activate

set imageSel to (get selection)

if imageSel is {} then

error "Please select some images."

else

repeat with im in imageSel

tell im

set the description to input

end tell

end repeat

end if

end tell

end run



User uploaded file

Save this workflow with a suitable name. It will be installed in the services.


  • Now quit Photos, if it is running and launch Photos again and select a few test images.
  • Open the "Photos" Menu > Services".
  • The service should be shown in the menu - I saved my version as "BatchChangeDescription".
  • Select the service to let it run.
  • You will be prompted to enter a new description for the selected photos.
  • When you click the selected photos again, the descriptions should change, but you will only see them in the Info panel, unlike the titles, that are showing below the thumbnails.


I put the service in my Dropbox:

https://www.dropbox.com/sh/g64e6sxd8qncg88/AADyqWgOuifcWsIqWwsO4W3va?dl=0


Comments

Jun 7, 2015 7:24 AM

Here is a second version, that you can try, if your library is a large iCloud Photo Library. Then the script may give errors, if the photos have not been selected in the "All Photos" album.

There is a work-around for this problem proposed by NicFletcher: Don't ask for the current selection, but add the photos you want to process to an album with a fixed name.

  • Create an album with a fixed name - mycurrentselection or similar - and add all photos you want to process to this album.
  • Instead of the "get current selection" process the photos in this album.


Here is a sample Apple Script by NicFletcher that uses this method:

https://discussions.apple.com/thread/6999613?answerId=28087786022#28087786022



I modified my script a bit to include Nic's fix. Also I added some code to catch errors and to try again on error after a short delay.


This version let's you select, if you want to pass the photos in an album with a fixed name, defined at the top-level, or if you want to select the photos in the "All Photos" album. The second version is working well on my iCloud Photo Library with 37000 photos, but the first version only on my smaller libraries, that do not use iCloud.


This code is meant to be run directly from the script editor. If you prefer to compile the script, add the "on run" clause.


--on run {input, parameters}


-- batch change the description of images to a string

(* How to use this script:


Open this script in Script Editor. Launch Photos.


The photos can be passed to the script in two ways:

1. Either select photos while viewing the "All Photos" album; this works better than Moments or smart albums

2. Or collect the Photos in a top level defined album with a fixed name.


If you want to select the photos without collecting them in an album, set the variable "ReadFromAlbum" to false

If you want to pass the photos in a toplevel album, set ReadFromAlbum to true and change the variable "theAlbumName" to the name of the album you are using.


When all all photo are selected or in the album and all parameters set, press the "Run" button in Scripteditor. The script will prompt you for the caption to be added to the photos.


*)


set ReadFromAlbum to true-- set this to true, if you want to pass the photos in a toplevel album

set theAlbumName to "PhotoDropBox" -- Enter the name of your album here.


set newDescription to text returned of (display dialog "Enter the new caption: " default answer "" buttons {"OK"} default button "OK")


set imageSel to {}


tell application "Photos"


activate

if (ReadFromAlbum) then -- the photos will be passed in a toplevel album named "PhotoDropBox"

set theAlbumName to "PhotoDropBox"


try


if existscontainertheAlbumName then


set thePhotosBuffer to containertheAlbumName

set imageSel to every media item of thePhotosBuffer

else

error "Album " & theAlbumName & "does not exist"

end if


on error errTexttwonumbererrNumtwo

display dialog "Cannot open album: " & errNumtwo & return & errTexttwo

end try


else -- process the selected photos from the All Photos album

try

set imageSel to (get selection)

on error errTexttwonumbererrNumtwo

display dialog "Cannot get the selection: " & errNumtwo & return & errTexttwo

end try


end if



-- check, if the album or the selected photos do contain images

if imageSel is {} then

error "Please select some images."

else

repeat with im in imageSel

try


tell im

set the description to newDescription

end tell

on error errText number errNum

display dialog "Error: " & errNum & return & errText & "Trying again"

try

delay 2

tell im

set the description to newDescription

end tell

on error errTexttwonumbererrNumtwo

display dialog "Skipping image due to repeated error: " & errNumtwo & return & errTexttwo

end try

end try

end repeat

end if

end tell

-- display dialog "Done"

return newDescription

--end run

Jun 7, 2015 7:24 AM

Jun 7, 2015 1:21 PM

Erratum:

I just discovered the first bug.


The line "settheAlbumNameto "PhotoDropBox" appears twice. The second copy of this line needs to be deleted or your changed album name will not take.


set ReadFromAlbum to true-- set this to true, if you want to pass the photos in a toplevel album

set theAlbumName to "PhotoDropBox" -- Enter the name of your album here.


set newDescription to text returned of (display dialog "Enter the new caption: " default answer "" buttons {"OK"} default button "OK")


set imageSel to {}


tell application "Photos"


activate

if (ReadFromAlbum) then -- the photos will be passed in a toplevel album named "PhotoDropBox"

-- set theAlbumName to "PhotoDropBox" --delete this line


try


if existscontainertheAlbumName then


set thePhotosBuffer to containertheAlbumName

set imageSel to every media item of thePhotosBuffer

else

error "Album " & theAlbumName & "does not exist"

end if


on error errTexttwonumbererrNumtwo

display dialog "Cannot open album: " & errNumtwo & return & errTexttwo

end try


else -- process the selected photos from the All Photos album

try

set imageSel to (get selection)

on error errTexttwonumbererrNumtwo

display dialog "Cannot get the selection: " & errNumtwo & return & errTexttwo

end try


end if



-- check, if the album or the selected photos do contain images

if imageSel is {} then

error "Please select some images."

else

repeat with im in imageSel

try


tell im

set the description to newDescription

end tell

on error errText number errNum

display dialog "Error: " & errNum & return & errText & "Trying again"

try

delay 2

tell im

set the description to newDescription

end tell

on error errTexttwonumbererrNumtwo

display dialog "Skipping image due to repeated error: " & errNumtwo & return & errTexttwo

end try

end try

end repeat

end if

end tell

-- display dialog "Done"

return newDescription

--end run

Jun 7, 2015 1:21 PM

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