Grumpy4u

Q: 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

Close

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

  • All replies
  • Helpful answers

Previous Page 2 of 6 last Next
  • by Grumpy4u,

    Grumpy4u Grumpy4u Apr 14, 2015 11:44 AM in response to léonie
    Level 1 (4 points)
    iLife
    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

  • by Reemibreak,

    Reemibreak Reemibreak Apr 15, 2015 8:52 AM in response to léonie
    Level 1 (0 points)
    Apr 15, 2015 8:52 AM in response to léonie

    Hello,

    I followed exactly what you did. I am trying to batch change and append a number to each photo but I keep receiving this error in Photos.

     

    Screen Shot 2015-04-15 at 11.14.43 AM.png

     

    Screen Shot 2015-04-15 at 11.31.02 AM.png

    This is my input in the AppleScript.

     

    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

  • by R C-R,Helpful

    R C-R R C-R Apr 15, 2015 11:49 AM in response to Grumpy4u
    Level 6 (17,633 points)
    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.

  • by Grumpy4u,

    Grumpy4u Grumpy4u Apr 15, 2015 10:12 PM in response to léonie
    Level 1 (4 points)
    iLife
    Apr 15, 2015 10:12 PM in response to léonie

    See above

  • by Grumpy4u,

    Grumpy4u Grumpy4u Apr 15, 2015 10:10 PM in response to Reemibreak
    Level 1 (4 points)
    iLife
    Apr 15, 2015 10:10 PM in response to Reemibreak

    Me too...

    Here is my script, followed by dialogs...

    Screen Shot 2015-04-15 at 9.45.43 PM.jpg

    Screen Shot 2015-04-15 at 9.46.25 PM.jpg

    Screen Shot 2015-04-15 at 9.47.43 PM.jpg

    Screen Shot 2015-04-15 at 9.48.29 PM.jpg

     

    I selected 3 photos, and clicked Run:

    Screen Shot 2015-04-15 at 9.49.20 PM.jpg

    Screen Shot 2015-04-15 at 9.49.35 PM.jpg

    Screen Shot 2015-04-15 at 9.49.54 PM.jpg

    Screen Shot 2015-04-15 at 9.50.04 PM.jpg

    Screen Shot 2015-04-15 at 9.50.20 PM.jpg

    So, it dies on the line:

         display dialog "filename: " & the filename of im

     

    It dies on any variation of:  the XXX of im

    it also dies on:

         set title to the name of im

     

    What's happening here?

  • by léonie,

    léonie léonie Apr 15, 2015 11:05 PM in response to Grumpy4u
    Level 10 (105,761 points)
    iLife
    Apr 15, 2015 11:05 PM in response to Grumpy4u

    The problem is, that your script is a mixture of two scripts -

    • the first script I posted to set the title for all selected images to the same text
    • and the second script to set the title to a filename plus title in answer to OT's question

    and the mixture ha undefined variables.

     

    If you want a script to ask for a new image title for all images, but append a number, do this:

    https://www.dropbox.com/sh/29exskbyuuffk5h/AAA-CDQ1fonab-TxSjvQBG-Ca?dl=0 (dropbox)

     

    Screen Shot 2015-04-16 at 08.02.41CEST.png


    on run {input, parameters}

      -- batch chnage the title to the input

      tell application "Photos"

      activate

      set counter to 1

      set imageSel to (get selection) -- get selected images

      if imageSel is {} then

      error "Please select some images."

      else

      repeat with im in imageSel

      tell im

      set the name to input & "_" & counter as text

      -- set the title to the input plus number

      set counter to counter + 1

      end tell

      end repeat

      end if

      end tell

      return input

    end run






  • by Grumpy4u,

    Grumpy4u Grumpy4u Apr 16, 2015 6:55 AM in response to léonie
    Level 1 (4 points)
    iLife
    Apr 16, 2015 6:55 AM in response to léonie

    Something else is not right.  Versions, not the same OS, something else....

     

    This is your script, with three display dialogs added.

    Screen Shot 2015-04-16 at 6.52.12 AM.jpg

    The three displays occur, and it dies right after, on the name (of im) reference.

    Can you explain why?

  • by Reemibreak,

    Reemibreak Reemibreak Apr 16, 2015 7:23 AM in response to Grumpy4u
    Level 1 (0 points)
    Apr 16, 2015 7:23 AM in response to Grumpy4u

    I am having the same problem as you Grumpy4u.

  • by Ben Bloks,

    Ben Bloks Ben Bloks Apr 16, 2015 7:49 AM in response to léonie
    Level 4 (2,302 points)
    Apr 16, 2015 7:49 AM in response to léonie

    @Léonie

     

    Thanks so much for your scripts. They run like a charm. Really happy with this .

     

    All the Best

     

    Ben

  • by R C-R,

    R C-R R C-R Apr 16, 2015 8:08 AM in response to Grumpy4u
    Level 6 (17,633 points)
    Apr 16, 2015 8:08 AM in response to Grumpy4u

    Did you set this up as service in Automator, & if so do you have exactly the same 'service receives' settings as léonie shows?

  • by Grumpy4u,

    Grumpy4u Grumpy4u Apr 16, 2015 1:17 PM in response to R C-R
    Level 1 (4 points)
    iLife
    Apr 16, 2015 1:17 PM in response to R C-R

    Yes...

    Screen Shot 2015-04-16 at 1.15.24 PM.jpg

    And it dies right after the third display command, on the set name....

    is it a permissions problem?

  • by Old Toad,

    Old Toad Old Toad Apr 16, 2015 3:09 PM in response to Grumpy4u
    Level 10 (140,913 points)
    Photos for Mac
    Apr 16, 2015 3:09 PM in response to Grumpy4u

    As a test launch Photos with the Option key held down and create a new, test library.  Import some photos and test to see if the same problem persists. Does it?

  • by Grumpy4u,

    Grumpy4u Grumpy4u Apr 16, 2015 8:46 PM in response to Old Toad
    Level 1 (4 points)
    iLife
    Apr 16, 2015 8:46 PM in response to Old Toad

    YES !

    The test library works properly.

    What do I need to reset on my primary library?

  • by Grumpy4u,

    Grumpy4u Grumpy4u Apr 16, 2015 10:10 PM in response to Grumpy4u
    Level 1 (4 points)
    iLife
    Apr 16, 2015 10:10 PM in response to Grumpy4u

    I did a Photo Library repair, to no avail.  It did not resolve the problem.

  • by Old Toad,

    Old Toad Old Toad Apr 17, 2015 8:51 AM in response to Grumpy4u
    Level 10 (140,913 points)
    Photos for Mac
    Apr 17, 2015 8:51 AM in response to Grumpy4u

    Go to Photos/General preference pane and there should be a button to make the library the System Photo Library.

    Photos001.jpg

    If the button is grayed out the that library is the System Photo Library.

Previous Page 2 of 6 last Next