Ziatron

Q: Help using leonie / Old Toad move text from "Keywords" to "Titles"

Need help using leonie / Old Toad move text from "Keywords" to "Titles".

 

I have 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.


So, I tried this Script:   Append Keywords to Title Field - Léonie's Script


It somewhat does the job, but not completely. 


When I select an image in Photos, and then, "Get Info" I will see the below in the title area, note that the first two lines are identical.


IMG_2621.JPG

IMG_2621.JPG

March 12, 2014  2:23 PM


My Keywords are:   Experimental Engine 17 at 600 Hours


AFTER I run the Script, I get the below:


IMG_2621.JPG - Experimental Engine 17 at 600 Hours

IMG_2621.JPG

March 12, 2014  2:23 PM


I need this to be: 


Experimental Engine 17 at 600 Hours

IMG_2621.JPG

March 12, 2014  2:23 PM


I don't understand why Photos shows the file name twice.   These fields are not labeled, but I was under the impression that the top line was the Description, the second line is the File Name, and the third line is the Date.   Because only the top line is shown under the thumbnails, I am trying to have the maximum amount of descriptive information appear in that area, (just as we could do with iPhoto or Aperture in the past).


In other words, when I run the script I would like my Keywords to completely replace everything in the top line, eliminating the file name. Is there anything wrong with this approach?  I would still have the file name in the second line, right?


Thanks.


Posted on Jun 10, 2016 8:42 AM

Close

Q: Help using leonie / Old Toad move text from "Keywords" to "Titles"

  • All replies
  • Helpful answers

Previous Page 2
  • by léonie,

    léonie léonie Jun 12, 2016 1:00 PM in response to Ziatron
    Level 10 (105,806 points)
    iCloud
    Jun 12, 2016 1:00 PM in response to Ziatron

    Try it on a few selected photos with keywords.  The filename should be omitted from the title and be replaced by the keywords, as long as this variable is set to true in the script.

    set replace_old_title to true --

  • by Ziatron,

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

    Hi léonie,

     

    As requested, I did more testing.   I did find one small glitch that hopefully you can help me with. If the Keyword field is blank, your script changes the Title of the image to, "missing value".    Would it be possible to have the script make the Title blank if the Keyword field is blank?   Please see image below.

     

    Screen Shot 2016-06-12 at 6.03.43 PM.png

  • by léonie,Solvedanswer

    léonie léonie Jun 13, 2016 3:23 AM in response to Ziatron
    Level 10 (105,806 points)
    iCloud
    Jun 13, 2016 3:23 AM in response to Ziatron

    I added a fix for the "missing value", see this download link:  https://dl.dropboxusercontent.com/u/45503699/PhotosBatchChangeTitleToKeywordsAlb umReplace.scpt.zip

     

     

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

     

    By default the old title will be overwritten.  If you want to append to the old title, set the variable replace_old_title to false.

    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 replace_old_title to true -- change this to false, if you want to append to the previous title

     

    -- 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 comma and space as the delimiter

      -- retrieve the keywords

     

      set kws to its keywords as string

      if not (exists kws) then

      set kws to ""

      end if

     

      if kws is "missing value" then

      set kws to ""

      end if

     

      if (replace_old_title) then

      set thename to "" -- the old title will be overwritten

      else

      set thename to its name

      if not (exists thename) then

      set thename to ""

      else --retrieve the old title

      set thename to thename & ", "

      end if

      end if -- (replace_old_title)

      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 comma and space as the delimiter

      -- retrieve the keywords

      set kws to its keywords as string

      if not (exists kws) then

      set kws to ""

      end if

      if kws is "missing value" then

      set kws to ""

      end if

     

     

      if (replace_old_title) then

      set thename to "" -- the old title will be overwritten

      else

      set thename to its name

      if not (exists thename) then

      set thename to ""

      else --retrieve the old title

      set thename to thename & ", "

      end if

      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 Ziatron,

    Ziatron Ziatron Jun 13, 2016 7:50 AM in response to léonie
    Level 4 (3,924 points)
    Apple Watch
    Jun 13, 2016 7:50 AM in response to léonie

    Your latest script appears to be working perfectly. I am unable to cause any issues or problems when using it. I have run it on a couple of my smaller libraries, it did its job flawlessly.

     

    In the next day or two I will run it on my larger libraries as well.

     

    I'd like to think that there are others out there with the same problem as me.   I remember well when Apple changed iPhoto so that it would no longer show Keywords below the Thumbnails, there were many many people complaining. They may have found other solutions outside of the Apple world.  Obviously, as I work with brand-new images I will add my descriptions to the Title field, NOT Keywords.

     

    I cannot thank you enough for your kind assistance.  It's great having someone like you in the Apple community. 


    Iéonie, a Level XI to me.

  • by léonie,

    léonie léonie Jun 13, 2016 7:53 AM in response to Ziatron
    Level 10 (105,806 points)
    iCloud
    Jun 13, 2016 7:53 AM in response to Ziatron

    You're very welcome, Ziatron

Previous Page 2