Ziatron

Q: Looking for a way to move text from "Keywords" to "Titles"

I started with iPhoto and later started using Aperture.  With iPhoto and Aperture you can have ANY metadata shown below the Thumbnails, (nice).  Well, I put descriptions of all of my, images in the Keywords section because it didn't matter.

 

Now I'm using that wonderful Photos program and I have discovered that it will ONLY show the "Title" of the image below the thumbnails.  I've got about 30,000 images with Keywords but NO Title.  I would like to move / copy the text from the Keyword section into the Title section.

 

léonie has written a prototype / experimental script that may accomplish this goal, (see link below), but to my knowledge, the script has not been tested and I know nothing about using scripts.  So, I would have to learn that as well.   I'm hoping for a easier solution.



Old Toad did some great scripts for Photos, but I need one more

Posted on May 27, 2016 9:39 AM

Close

Q: Looking for a way to move text from "Keywords" to "Titles"

  • All replies
  • Helpful answers

Page 1 Next
  • by Old Toad,

    Old Toad Old Toad May 27, 2016 10:34 AM in response to Ziatron
    Level 10 (140,881 points)
    Photos for Mac
    May 27, 2016 10:34 AM in response to Ziatron

    I made some changes to the script but can't get the keywords to be separated.  I added a dash so that the grouped keywords would come after whatever title was already there departed by the dash.

    2016-05-27 10.25.38.gif

    Here's the script as I modified it - changes are in bold red. The script can be used on a photo anywhere in the library, i.e. in any album Moment (Photos) or All Photos.

    -- batch change the title of images to the keywords

    (* 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.

    *)

     

    set ReadFromAlbum to false

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

    set theAlbumName to "PhotoDropBox" -- change this to the name of the album you will use

     

     

    set imageSel to {}

     

    tell application "Photos"

      activate

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

     

      try

     

      if exists container theAlbumName then

     

      set thePhotosBuffer to container theAlbumName

      set imageSel to every media item of thePhotosBuffer

      else

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

      end if

     

      on error errTexttwo number errNumtwo

      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 errTexttwo number errNumtwo

      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

      -- retrieve the keywords

      set kws to its keywords as string

      if not (exists kws) then

      set kws to ""

      end if

     

      --retrieve the old title

      set thename to its name

      if not (exists thename) then

      set thename to ""

      else

      set thename to thename & " "

      end if

      set its name to thename & "- " & kws

      end tell

      on error errText number errNum

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

      try

      delay 2 -- wait and try again

      tell im

      -- retrieve the keywords

      set kws to its keywords as string

      if not (exists kws) then

      set kws to ""

      end if

     

      --retrieve the old title

      set thename to its name

      if not (exists thename) then

      set thename to ""

      else

      set thename to thename & " "

      end if

      set its name to thename & "- " & kws

      end tell

      on error errTexttwo number errNumtwo

      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 "Done"

    I'm still trying to find out if I can get the keywords to be separated by spaces or commas.

     

    In the meantime you can use PowerPhotos  to view the photos with the keyword below the thumbnail:

    PowerPhotos001.jpg

    OTsig.png

  • by léonie,

    léonie léonie May 27, 2016 11:26 AM in response to Old Toad
    Level 10 (105,249 points)
    iLife
    May 27, 2016 11:26 AM in response to Old Toad

    This version will separate the keywords by spaces:

     

    What I added is:

    • retrieve the current  text item delimiter to save it to a local variable. By default this is empty, so all keywords will be glued together

    set saved_delimiter to AppleScript's text item delimiters --save the delimiter


     

    • Add a list of custom text item delimiters,

      set AppleScript's text item delimiters to {" "} --use a space as the delimiter

    • Restore the default delimiter when the script is done.  This is essential, because other wise other scripts may not work afterward.

    set AppleScript's text item delimiters to saved_delimiter --restore  the delimiter


     

    -- batch change the title of images to the keywords

    (* 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.

    *)

    -- return AppleScript's text item delimiters

     

    set ReadFromAlbum to true

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

    set theAlbumName to "PhotoDropBox" -- change this to the name of the album you will use

     

     

    set imageSel to {}

    set saved_delimiter to AppleScript's text item delimiters --save the delimiter

     

     

    tell application "Photos"

      activate

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

     

      try

     

      if exists container theAlbumName then

     

      set thePhotosBuffer to container theAlbumName

      set imageSel to every media item of thePhotosBuffer

      else

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

      end if

     

      on error errTexttwo number errNumtwo

      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 errTexttwo number errNumtwo

      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 text item delimiter

      set AppleScript's text item delimiters to {" "} --use a space as the delimiter

      -- retrieve the keywords

     

      set kws to its keywords as string

      if not (exists kws) then

      set kws to ""

      end if

     

      --retrieve the old title

      set thename to its name

      if not (exists thename) then

      set thename to ""

      else

      set thename to thename & " "

      end if

      set its name to thename & kws

      end tell

      on error errText number errNum

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

      try

      delay 2 -- wait and try again

      tell im

      set AppleScript's text item delimiters to {" "} --use a space as the delimiter

      -- retrieve the keywords

      set kws to its keywords as string

      if not (exists kws) then

      set kws to ""

      end if

     

      --retrieve the old title

      set thename to its name

      if not (exists thename) then

      set thename to ""

      else

      set thename to thename & ", "

      end if

      set its name to thename & kws

      end tell

      on error errTexttwo number errNumtwo

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

      end try

      end try

      end repeat

      end if

    end tell

    -- display dialog "Done"

    set AppleScript's text item delimiters to saved_delimiter --restore  the delimiter

     

    return "Done"

  • by Old Toad,

    Old Toad Old Toad May 27, 2016 11:45 AM in response to léonie
    Level 10 (140,881 points)
    Photos for Mac
    May 27, 2016 11:45 AM in response to léonie

    Thanks.  I've modified your last script a bit to give this as the title and to not look for a particular album:

    Photos001.jpg

     

    If anyone is interested in it let me know.

  • by Ziatron,

    Ziatron Ziatron May 28, 2016 7:46 PM in response to Old Toad
    Level 4 (3,924 points)
    Apple Watch
    May 28, 2016 7:46 PM in response to Old Toad

    If anyone is interested in it let me know.

    I am very interested.  I know nothing about AppleScript but I am willing to put in a certain amount of effort to avoid cut and pasting 30,000 times !!

     

    Is AppleScript now called "Script Editor" ?    I found this in my Utilities folder

     

    Is this a good place to start learning about AppleScript?

     

    http://macosxautomation.com/applescript/firsttutorial/index.html

     

    You mentioned that you modified the above code.  Where is the code that you modified?  If possible, I would like to move the exact text that I now having Keywords, to Titles. Does your code do this?

     

    It looks like Old Toad and Leonie have done the heavy lifting here.  I have to figure out where to start.

  • by iOSAdvisorAsh,

    iOSAdvisorAsh iOSAdvisorAsh May 28, 2016 8:15 PM in response to Ziatron
    Level 1 (40 points)
    iPhone
    May 28, 2016 8:15 PM in response to Ziatron

    Ziatron wrote:

     

    I started with iPhoto and later started using Aperture.  With iPhoto and Aperture you can have ANY metadata shown below the Thumbnails, (nice).  Well, I put descriptions of all of my, images in the Keywords section because it didn't matter.

     

    Now I'm using that wonderful Photos program and I have discovered that it will ONLY show the "Title" of the image below the thumbnails.  I've got about 30,000 images with Keywords but NO Title.  I would like to move / copy the text from the Keyword section into the Title section.

     

    léonie has written a prototype / experimental script that may accomplish this goal, (see link below), but to my knowledge, the script has not been tested and I know nothing about using scripts.  So, I would have to learn that as well.   I'm hoping for a easier solution.



    Old Toad did some great scripts for Photos, but I need one more

     

     

    HI Ziatron,

     

          I found your dilemma quite interesting and I see the problem you are running into here.

     

    I recall a video I watched just the other day that helped me to get my Photo library not only organized by Keywords, but REALLY organized by using Keywwords. :-) You can view the same video by clicking the following link and viewing the YouTube video: http://youtu.be/9ZW7PItHouY

     

    I also stumbled across the little gem I have linked below⤵️, and Old Toad happened to provide, yet again, some valuable input I think you can use! I hope this has helped you guys :-D

    Batch Changing the Titles to the Filename w/Extension

     

    -Ashley H.

  • by léonie,

    léonie léonie May 29, 2016 12:35 AM in response to Ziatron
    Level 10 (105,249 points)
    iLife
    May 29, 2016 12:35 AM in response to Ziatron

    Is AppleScript now called "Script Editor" ?    I found this in my Utilities folder

    "Apple Script" is the name of a programming language to write scripts. Some commands are described here:  http://help.apple.com/applescript/mac/10.9/#apscrpt1001

     

    Previous OS X versions hd a tool named AppleScript Editor.

    Now there is the newer Script Editor, that will for other scripting languages as well.

     


  • by Old Toad,

    Old Toad Old Toad May 29, 2016 10:47 AM in response to Ziatron
    Level 10 (140,881 points)
    Photos for Mac
    May 29, 2016 10:47 AM in response to Ziatron

    Here's the code that gives me the keywords tacked on to the existing Title.  It's léonie's script with three changes (in bold red):

    -- batch change the title of images to the keywords

    (* 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.

    *)

    -- return AppleScript's text item delimiters

     

    set ReadFromAlbum to false

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

    set theAlbumName to "PhotoDropBox" -- change this to the name of the album you will use

     

     

    set imageSel to {}

    set saved_delimiter to AppleScript's text item delimiters --save the delimiter

     

     

    tell application "Photos"

      activate

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

     

      try

     

      if exists container theAlbumName then

     

      set thePhotosBuffer to container theAlbumName

      set imageSel to every media item of thePhotosBuffer

      else

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

      end if

     

      on error errTexttwo number errNumtwo

      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 errTexttwo number errNumtwo

      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 text item delimiter

      set AppleScript's text item delimiters to {", "} --use a space as the delimiter

      -- retrieve the keywords

     

      set kws to its keywords as string

      if not (exists kws) then

      set kws to ""

      end if

     

      --retrieve the old title

      set thename to its name

      if not (exists thename) then

      set thename to ""

      else

      set thename to thename & " "

      end if

      set its name to thename & "- " & kws

      end tell

      on error errText number errNum

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

      try

      delay 2 -- wait and try again

      tell im

      set AppleScript's text item delimiters to {", "} --use a space as the delimiter

      -- retrieve the keywords

      set kws to its keywords as string

      if not (exists kws) then

      set kws to ""

      end if

     

      --retrieve the old title

      set thename to its name

      if not (exists thename) then

      set thename to ""

      else

      set thename to thename & ", "

      end if

      set its name to thename & "- " & kws

      end tell

      on error errTexttwo number errNumtwo

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

      end try

      end try

      end repeat

      end if

    end tell

    -- display dialog "Done"

    set AppleScript's text item delimiters to saved_delimiter --restore  the delimiter

     

    return "Done"

     

  • by léonie,

    léonie léonie May 29, 2016 10:56 AM in response to Old Toad
    Level 10 (105,249 points)
    iLife
    May 29, 2016 10:56 AM in response to Old Toad

    Nice, OT

     

    For an iCloud Photo Library I would set "set ReadFromAlbum to false"  back to "true".

    The Current Selection is still not working reliable in El Capitan with iCloud Photo Library. But for a local Photos Library it should work just fine.

  • by Ziatron,

    Ziatron Ziatron May 29, 2016 12:54 PM in response to léonie
    Level 4 (3,924 points)
    Apple Watch
    May 29, 2016 12:54 PM in response to léonie

    For an iCloud Photo Library I would set "set ReadFromAlbum to false"  back to "true".

     

    I am not using iCloud with Photos.  So, could I use the code straight away as shown above?   Perhaps it doesn't matter either way?

  • by léonie,

    léonie léonie May 29, 2016 12:59 PM in response to Ziatron
    Level 10 (105,249 points)
    iLife
    May 29, 2016 12:59 PM in response to Ziatron

    It should work. But I can only test with iCloud.

    Test it on a small test library before you try it on your main library.

     

    And keep a backup of your library before you try to edit large batches of photos.

  • by Old Toad,

    Old Toad Old Toad May 29, 2016 3:43 PM in response to Ziatron
    Level 10 (140,881 points)
    Photos for Mac
    May 29, 2016 3:43 PM in response to Ziatron
  • by Ziatron,

    Ziatron Ziatron Jun 9, 2016 9:04 PM in response to Old Toad
    Level 4 (3,924 points)
    Apple Watch
    Jun 9, 2016 9:04 PM in response to Old Toad

    Here's the code that gives me the keywords tacked on to the existing Title.

     

    For what it's worth, I am not using the cloud with Photos. I store everything locally only.

     

    Right now, my images do not have a Title.  However, for some reason Photos is showing the file name below each thumbnail, for example, "IMG_2621.JPG".

    when I do, "Get Info" the title area is blank.   If I'm able to successfully run your script I'm hoping to ONLY have the title below each thumbnail without the file name. Is this how it will work?  I assume that the actual file name will always be accessible by utilizing "Get Info".

     

    Open this script in Script Editor.

     

    I am a little fuzzy on where your instructions end, and the script begins.  When you say, "open this script",  I am under the impression I should copy certain text into the script editor. If so, help me clearly understand the beginning and end points.   Typically, my Keywords, (that I'm trying to move to Titles) are 4 to 8 words long, so I would like to have the appropriate spaces in between the words. Basically, I'm trying to copy the Keywords exactly as written into the title area.

  • by Old Toad,

    Old Toad Old Toad Jun 10, 2016 9:46 AM in response to Ziatron
    Level 10 (140,881 points)
    Photos for Mac
    Jun 10, 2016 9:46 AM in response to Ziatron

    You can add everything from that reply that's in the quoted area. It will include the instruction.  Or you can just include the following and save as an application. 

    set ReadFromAlbum to false

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

    set theAlbumName to "PhotoDropBox" -- change this to the name of the album you will use

     

     

    set imageSel to {}

     

    tell application "Photos"

      activate

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

     

      try

     

      if exists container theAlbumName then

     

      set thePhotosBuffer to container theAlbumName

      set imageSel to every media item of thePhotosBuffer

      else

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

      end if

     

      on error errTexttwo number errNumtwo

      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 errTexttwo number errNumtwo

      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

      -- retrieve the keywords

      set kws to its keywords as string

      if not (exists kws) then

      set kws to ""

      end if

     

      --retrieve the old title

      set thename to its name

      if not (exists thename) then

      set thename to ""

      else

      set thename to thename & " "

      end if

      set its name to thename & "- " & kws

      end tell

      on error errText number errNum

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

      try

      delay 2 -- wait and try again

      tell im

      -- retrieve the keywords

      set kws to its keywords as string

      if not (exists kws) then

      set kws to ""

      end if

     

      --retrieve the old title

      set thename to its name

      if not (exists thename) then

      set thename to ""

      else

      set thename to thename & " "

      end if

      set its name to thename & "- " & kws

      end tell

      on error errTexttwo number errNumtwo

      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 "Done"

  • by Ziatron,

    Ziatron Ziatron Jun 10, 2016 11:57 AM in response to Old Toad
    Level 4 (3,924 points)
    Apple Watch
    Jun 10, 2016 11:57 AM in response to Old Toad

    Thanks OT,

     

    I have learned how to run scripts!!   I believe I have successfully run the script referenced above. However, another issue cropped up related to the script, I have posted my problem here:  Help using leonie / Old Toad move text from "Keywords" to "Titles"

     

    Please take a look for me.

     

    Thanks

Page 1 Next