The Robservatory

Robservations on everything…

 

Assign a photo’s Title field based on its filename in Photos

My migration from iPhoto to Photos continues, and today’s snafu was my discovery that I couldn’t rename files in Photos. This is something I’ve long done in iPhoto—not for every file, but for ones I’d like to group together using something other than Keywords.

For example, I have a collection of iOS wallpapers, for both the home and lock screens. I name each with either “H_” or “L_” as the start of the filename, which let me create this Smart Album to see them all together:

The inability to rename files isn’t critical, in particular because the Title field can be used for the same functionality. But I had a problem: When I migrated, Photos created Titles for some, but not all, of my custom-named images. In particular, it missed all of the iOS wallpapers. I’m not sure if this is because these aren’t photos in the traditional sense—they’re edited photos I export as PNGs. But whatever the reason, I had hundreds of images that needed a Title that was equal to their Filename.

AppleScript to the rescue…this simple bit of code acts on the selection in Photos, and sets the Title equal to each image’s filename.

To use this bit of code, just select the photos you’d like to modify in Photos, then run the script. You can make it a bit easier by saving the script into your user’s Library > Scripts > Applications > Photos folder (create as many of those as don’t exist). It will then be available in the AppleScript menu in the menu bar, assuming you’ve enabled that in the AppleScript Editor’s preferences.

This saved me literally hours of work, copying and pasting filenames to the Title field. (I was surprised this worked, but it did—you can’t change the filename, but you can select and copy it.)

3 Comments

Add a Comment
  1. How would you compare scriptability in Photos compared to Aperture? The extensive scriptable hooks in Aperture were one of the things that made it so awesome. I’m still on Mavericks so haven’t had a chance to check out the Applescript Dictionary for Photos.app to see how deeply they’ve embedded the scripting interface.

    1. I’m far from a scripting expert, but I’d describe Photos AppleScript support as relatively basic, especially when compared to Aperture. Here’s a huge screenshot showing the dictionaries for each; Aperture’s is clearly much deeper.

      -rob.

  2. Ah, I see the metadata support is pretty shallow – and manipulating EXIF and IPTC metadata fields was my main use for Aperture scripting. And of course that would be the one area where 3rd party developers would not be able to add much value to Photos…

Leave a Reply

The Robservatory © 2017 Built from the Frontier theme