Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Is there a way to do batch changes in Photos (like we could in iPhoto)?

I made heavy use of the Batch change command in iPhoto.

Now that I'm in Photos, how can I get the same results?

Specifically the Batch change of title....

Mac Pro, OS X Yosemite (10.10.3)

Posted on Apr 11, 2015 9:47 PM

Reply
2 replies
Question marked as Helpful

Apr 15, 2015 11:49 AM in response to Grumpy4u

Grumpy4u wrote:

Where can I see the allowed/defined properties of an image?

In the Applescript dictionary for Photos. You can access that through Script Editor (in your Utilities folder). Open Script Editor & from the File menu, choose "Open Dictionary..." then navigate to Photos in your Applications folder & choose it.


Look for the entry in the dictionary for media item (the object type for photos & videos) -- it is part of the Photos Suite. It will look like this, but with better formatting:


media item n : A media item, such as a photo or video.

elements

contained by application, albums, moments.

properties

keywords (list of text) : A list of keywords to associate with a media item

name (text) : The name (title) of the media item.

description (text) : A description of the media item.

favorite (boolean) : Whether the media item has been favorited.

date (date) : The date of the media item

id (text, r/o) : The unique ID of the media item

height (integer, r/o) : The height of the media item in pixels.

width (integer, r/o) : The width of the media item in pixels.

filename (text, r/o) : The name of the file on disk.

altitude (real, r/o) : The GPS altitude in meters.

location (list of real, r/o) : The GPS latitude and longitude, in an ordered list of 2 numbers. Latitude in range -90.0 to 90.0, longitude in range -180.0 to 180.0.

responds to

duplicate.

87 replies

Apr 12, 2015 8:10 AM in response to Grumpy4u

To batch change the titles 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:

I put a copy of the finished workflow into my Dropbox, if you want to try it: https://www.dropbox.com/sh/r6kf61oiktntt3q/AADJtXaEuB38OZY0H0PWEIPfa?dl=0


The Apple Script:


on run {input, parameters}

-- batch chnage the title 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 name to input

end tell

end repeat

end if

end tell

return input

end run


Launch Automator,

  • create a new service,
  • drag a "Ask for Text" action into the workflow.
  • drag a "Run Apple Script" action into the workflow.

Copy and paste the text above into the "Run Apple Script" action to replace the default text in the action.


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 "BatchChangeTitles".
  • Select the service to let it run.
  • You will be prompted to enter a new title for the selected photos.
  • When you click the selected photos again, the titles should change.

Apr 13, 2015 2:29 PM in response to Old Toad

Like this:


I'd add a variable "counter" that will be incremented for each new file. then append this counter to the filename (the "&" operator appends strings and converts numbers to strings)


tell application "Photos"

activate

set imageSel to (get selection) -- get a list of selected images

set counter to 1

set currentfilename to ""

if imageSel is {} then

error "Please select an image."

else

repeat with im in imageSel

set title to the name of im

if not (exists (title)) then

set currentfilename to the filename of im as text -- retrieve the filename of image "Im"

set newname to currentfilename & "." & counter

set counter to counter + 1 -- increment the counter

set the name of im to newname -- write the newname to the title field

end if

end repeat

end if

return currentfilename -- return the filename of the last image

end tell


The spellchecker is continually corrupting the code😟 I hope, I found all "corrections"

Apr 13, 2015 3:42 PM in response to Old Toad

Works as advertised this way.

I see you have already a nice collection!


Perhaps I should make a Photos version of my Aperture script, that sets the time of all selected selected photos to the same date, and increments it by a fixed step for each photo, like iPhotos batch change time does. I use that script mainly for scanned slides.

Apr 13, 2015 5:52 PM in response to léonie

User uploaded fileRestarting the system was required.

Now I see the service, but I'm getting an error.

Code:


-- batch change the title to the input

tell application "Photos"

activate
set counter to 1
set imageSel to (get selection) -- get a list of selected images
if imageSel is {} then
error "Please select an image."
else
repeat with im in imageSel
set title to the name of im
-- if not (exists (title)) then
set newname to input & "." & counter
set counter to counter + 1 -- increment the counter
set the name of im to newname -- write the new title field
-- end if
end repeat
end if

end tell

return input

end run

User uploaded file

What line is in error?

User uploaded file

Apr 14, 2015 9:02 AM in response to Grumpy4u

In the fragment, that you posted the first line "on run {input, parameters}" is missing, so the variable "input" in the last line "return input" is undefined.


What are you trying to do?


That looks now like a mixture of the first script I posted, to change the title to string, that is read from a user input,

and the second script, that I posted in answer to old Toad's question about setting the title to the filename.


Which of the two batch changes do you want to do?

Apr 14, 2015 11:44 AM in response to léonie

My paste was in error, I did have the first line

"on run {input, parameters}"

But Failed to include it in my last post...

So, where is the error...

If nothing is selected, I do get the statement -- error "Please select an image."

So, with a selection, it does get to the else that follows

Is name a property of im? (an image)

Where can I see the allowed/defined properties of an image?

Thanks

Is there a way to do batch changes in Photos (like we could in iPhoto)?

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