1 2 Previous Next 16 Replies Latest reply: May 2, 2012 9:45 AM by Frank Caggiano
pmaheshwari Level 1 Level 1 (0 points)

 

Hi there,

 

I would appreciate if some appliecript guru can help me out here , I have names of files in a text file / clipboard from which I would like to make a smart album / normal album. Is there any way to automate this process .

 

Currently I am using smart albums -> text-> filename A, , text->filename B etc for 50-60 items.

 

Help

 

 

I hunted the net and found Make album from a list of version name, but alas it was no where to be found as aperture assistant is no more.


Aperture 3, Mac OS X (10.7.3)
  • 1. Re: Applescript for Making album from filename in text/clipboard
    Frank Caggiano Level 7 Level 7 (23,830 points)

    Are you looking for a push in the right direction on this or are you looking for a done script?

     

    If the formaer have a look at Aperture Service: Target Album/Quick Collection for a group of scripts that creeate and populate Albums on the fly. Of the three scripts in that package setTargetAlbum is the script that most likely will get you going making Albums in Aperture.

     

    If you need more thne just a push I'll try and get to look at thois later in the weekend if no one does anything with it before that.

     

     

    Just remebered that the file you will download is acyually an Automator workflow. Just opne the workflow in Automator and extract the Applescript into the Applescript editor.

     

    regards

     

    A quick jump start

     

    tell application "Aperture"

                        tell library 1

      make new album with properties {name:newAlbum}

                        end tell

              end tell



    is all you need to do to make an album in Aperture via Applescript. So you need to figure out how to loop through your list of album names and set newAlbum to the text.

  • 2. Re: Applescript for Making album from filename in text/clipboard
    léonie Level 9 Level 9 (51,705 points)

    Great script, Frank.

     

    That part of Aperture scripting I still find puzzling:

    tell library 1

    ...

    end tell

     

    Is there a rule how to find out the library numbers? So far I always use number "1" and hope for the best, since you can only have one library open

     

    Cheers

    Léonie

  • 3. Re: Applescript for Making album from filename in text/clipboard
    Frank Caggiano Level 7 Level 7 (23,830 points)

    You're right there is only one library (when I first saw that I was hoping you could actually access other libraries or access by name but no...)

     

    In most cases it is actually redundant. I don't think I've ever run across a case where having that in or out made a difference. This is a snippet from an older script when I was doing everything by the book. If I wrote it now I'd probably leave it out.

  • 4. Re: Applescript for Making album from filename in text/clipboard
    léonie Level 9 Level 9 (51,705 points)

    I don't think I've ever run across a case where having that in or out made a difference.

    If I remember correctly it sometimes it is essential - I came across some messages that Aperture did not seem to understand, but the library does - that might be a coincidence and the problem was something completely different.

     

    But it would be great to have an Aperture scripting guide; I just hate to have to learn everything by trial and error

  • 5. Re: Applescript for Making album from filename in text/clipboard
    Frank Caggiano Level 7 Level 7 (23,830 points)
  • 6. Re: Applescript for Making album from filename in text/clipboard
    léonie Level 9 Level 9 (51,705 points)

    Great, thank you for posting that much better than nothing

  • 7. Re: Applescript for Making album from filename in text/clipboard
    pmaheshwari Level 1 Level 1 (0 points)

    Thank you for the sample script , I did see that in reference file.


    I don't think I require a loop , I require some sort of container , where in I can specify list of version to keep inside the created album

     

    tell application "Aperture"

                        tell library 1

      make new album with properties {name:newAlbum}

    (The version inside this album = clipboard items)                    

    end tell

              end tell

     

     

    I'm a complete newbie to programming and find this a little difficult

  • 8. Re: Applescript for Making album from filename in text/clipboard
    Frank Caggiano Level 7 Level 7 (23,830 points)

    Ok try something like this:

     

     

    set albumList to {"album 1", "album 2", "album 3"}
    
    tell application "Aperture"
              tell library 1
                   repeat with i in albumList
                              make new album with properties {name:i}
                   end repeat
              end tell
    end tell
    
    
    
    

     

    You can edit the line

    set albumList to {"album 1", "album 2", "album 3"}

    to hold the names for your albums. just make sure the names are in  quotes and a comma seperates each entry.

     

    If the names you want to use are in a text file let me know the format of the text file (one name per line, comma seperated list, etc)

  • 9. Re: Applescript for Making album from filename in text/clipboard
    pmaheshwari Level 1 Level 1 (0 points)

    Thanks Frank , Thank for the swifty reply

     

    My text file looks like this (these are the images names)

    KB-SCR-12202

    KB-SCR-12211

    KB-SCR-12220

    KB-SCR-11627

    KB-SCR-12219

    KB-SCR-12172

    KB-PR-01369

    KB-PR-01131-A

    KB-PR-0912-C

     

     

    Instead of Text file,  I would prefer the clipboard approach . I've these names in clipboard

     

    Instead of making multiple albums as you've given up , I want to create just 1 album with the images names listed above (KB-SCR-12202,KB-SCR-12211 etc..)

  • 10. Re: Applescript for Making album from filename in text/clipboard
    Frank Caggiano Level 7 Level 7 (23,830 points)

    Instead of making multiple albums as you've given up , I want to create just 1 album with the versions equivalent to images names listed above (KB-SCR-12202,KB-SCR-12211 etc..)

    OK I'm missing something here.  If you don't want albums (which is what your original post asked for) I'm not sure what it is you're looking to do then.

     

    You write that these are image names, ok where are the images? Are you actually looking to move these images into an album? Are the images in Aperture already?

  • 11. Re: Applescript for Making album from filename in text/clipboard
    pmaheshwari Level 1 Level 1 (0 points)

    All the images are already inside Aperture.

     

    Here's the scenario

    • I've an aperture library of 5000 images which contains all the items i've. I'm currently sitting in HongKong fair , when a buyer comes and selects few items , I write the name of items selected in a text file quickly along with other changes suggested by a customer.
    • At the end of day , I create albums 1 by 1 for each buyer who came & manually add items . So I can email each buyers items he/she selected.
    • This is the process I want to automate , so once I've the names of images in a text file , I select content in clipboard , fire up the applescript and an album is created ,populated with images .

     

    I hope I'm clear.

  • 12. Re: Applescript for Making album from filename in text/clipboard
    Frank Caggiano Level 7 Level 7 (23,830 points)

    Ok that's clearer. One last question does the buyer select from within Aperture or do you have proofs that the buyer is looking at?

     

    if the buyer is selecting from within Aperture then it would be simplest to just create the album of the picks in real time.

     

    If he is not in Aperture then doing it by Applescript is feasible. I'll need to look at it to it tomorrow.

  • 13. Re: Applescript for Making album from filename in text/clipboard
    pmaheshwari Level 1 Level 1 (0 points)

    No buyer doesn't select from Aperture , in the fair I've most of  items laid out ,buyer just selects the items physically & keeps them in a stack , once buyer is gone , I write down everything manually.

  • 14. Re: Applescript for Making album from filename in text/clipboard
    Frank Caggiano Level 7 Level 7 (23,830 points)

    OK here's a script that you can play around with.  It will read a comma separated list of version names and move them to an Album it creates that is the same as the name of the file.

     

    So if you create a file, say Customer1 and then add the version names to the file for this customer as

    IMG_001,IMG_002,IMG_003

     

    Then when the script is done running you will have an album Customer1 containing the versions specified.

     

    Note: There isn't a lot of error checking so I would suggest you play around with this on a test library first.

     

     

    set imageVersions to {}

    set newAlbum to ""

     

    set f to (choose file with prompt "Pick image name file") as string

     

    tell application "System Events"

              set fname to name of disk item f

              set ext to name extension of disk item f

    end tell

     

    if ext is not "" then

              set _length to (count of fname) - (count of ext) - 1

              set newAlbum to text 1 thru _length of fname

    else

              set newAlbum to fname

    end if

     

    set fn to open for access file f

    try

              set imageVersions to read fn using delimiter ","

    on error number -39

           close access fn

    end try

     

    close access fn

     

    tell application "Aperture"

              tell library 1

              make new album with properties {name:newAlbum}

     

                        set aa to (every image version)

                        repeat with i in aa

                                  if name of i is in imageVersions then

                                            try

                               duplicate i to album newAlbum

                                            on error es number n

                                                      if n ≠ -1717 then

                                                                display dialog "Unknow error " & n & return & es

                                                      end if

                                            end try

                                  end if

                        end repeat

              end tell

    end tell


1 2 Previous Next