Sebibi

Q: Photos : change title of several pictures Applescript error

Hello,

 

My problem is that Photos does not support Several Pictures title change .... I am waiting El Capitan to provide this functionality. In the meantime, I am trying Applescript to do it myself.. There are a lot of articles and solution like Batch Changes in Photos for Mac: Change the titles to a Given String.. Thanks to the author... It works fine on one Mac I have BUT on the other Mac with my Photos Library I got the following error :

 

tel

tell application "Photos"

  get selection

  --> {media item id "ZRc4fsCATY6Hwr0noYG3Qg"}

  get filename of media item id "ZRc4fsCATY6Hwr0noYG3Qg"

  --> error number -10000

Résultat :

error "Erreur dans Photos : Le gestionnaire AppleEvent a échoué." number -10000

GOOGLE translates it to "Error in Photos: The AppleEvent manager failed."

 

My Applescript code is easy, you just need to select one pic in Photos to use it.

 

tell application "Photos"

  set selected to selection

  repeat with img in selected

  set oldName to the filename of img

  log oldName

  end repeat

end tell

 

 

How can I get deeper to understand what is wrong ? I suspect rights/privileges problem, or write permissions on pictures, or OS X update to redo ...  please help.

How to change the message label from french to the english to be understood here ?

 

Thank in advance

MacBook Pro, OS X Yosemite (10.10.5), null

Posted on Sep 4, 2015 11:47 PM

Close

Q: Photos : change title of several pictures Applescript error

  • All replies
  • Helpful answers

  • by léonie,

    léonie léonie Sep 5, 2015 2:40 AM in response to Sebibi
    Level 10 (105,543 points)
    iLife
    Sep 5, 2015 2:40 AM in response to Sebibi

    The "Get Selection" action is not working well, if you are using iCloud Photo Library.  Do you have iCloud Photo Library enabled?

    If you have, it works better to create a top-level album with a fixed name and to retrieve all photos in that album as proposed by NicFletcher

     

    This method is described in the second version of the script:   Script:  Batch Change the Descriptions

    (the last post in that discussion)  Try to adapt the script to change the titles instead of the descriptions.

    Or use this script as a template (again the second version):  Script: Batch Changing the Titles to the Filename w/Extension

     

    Another problem might be, that you are currently using MacOS X 10.10.5.  All published scripts have been tested with MacOS X 10.10.4, but not with the latest release.  Old Toad told me, that some of the scripts appear to be broken in MacOS X 10.10.5.

  • by Sebibi,

    Sebibi Sebibi Sep 5, 2015 4:52 AM in response to léonie
    Level 1 (0 points)
    Sep 5, 2015 4:52 AM in response to léonie

    Thanks for your warning information.. I discovered indeed that selection is a little buggy so far.. but here it is not the problem of selection, since the output of my script wrote :

    get selection

      --> {media item id "ZRc4fsCATY6Hwr0noYG3Qg"}

    It proves that selection works with my picture I selected.

    Then I try to get the property filename of the picture with  the filename of img .... and -10000 occurred !!

    My question is more about to get detail of this -10000 error code .. nothing in Applescript manuel, where shall I get information ? sys event ?

     

    Note that I got the same error with only one Applescript command line :

    get the filename of media item id "ZRc4fsCATY6Hwr0noYG3Qg"

    without using selection.

  • by léonie,

    léonie léonie Sep 5, 2015 5:07 AM in response to Sebibi
    Level 10 (105,543 points)
    iLife
    Sep 5, 2015 5:07 AM in response to Sebibi

    I never got the media item id to work.

    It always resulted in the error message you are quoting.

    So I avoid to access the media items using the id.

    And access it sending the message directly to the object:

    tell im

      set its name to its filename

      end tell



    For more expert advice on Apple Script you may want to ask in the forum:

         Mac OS X Technologies

  • by Sebibi,

    Sebibi Sebibi Sep 5, 2015 6:54 AM in response to léonie
    Level 1 (0 points)
    Sep 5, 2015 6:54 AM in response to léonie

    Ok to avoid media item ... I try the code :

     

    tell application "Photos"

      set selected to selection

      repeat with img in selected

      tell img

      set its name to the filename of img

      end tell

      end repeat

    end tell


    I got the same error : -10000. I gonna ask the same question to the other forum : Mac OS X Technologies

    Thanks.