Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript for Making album from filename in text/clipboard


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)

Posted on Apr 27, 2012 8:58 PM

Reply
16 replies

Apr 28, 2012 8:16 AM in response to pmaheshwari

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


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

Apr 28, 2012 8:45 AM in response to léonie

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

Apr 28, 2012 8:57 AM in response to Frank Caggiano

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 😠

Apr 29, 2012 7:21 PM in response to Frank Caggiano

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


makenewalbumwith 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

Apr 29, 2012 7:31 PM in response to pmaheshwari

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)

Apr 29, 2012 7:37 PM in response to Frank Caggiano

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

Apr 29, 2012 7:43 PM in response to pmaheshwari

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?

Apr 29, 2012 7:48 PM in response to Frank Caggiano

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.

Apr 29, 2012 7:58 PM in response to pmaheshwari

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.

Apr 30, 2012 1:25 PM in response to pmaheshwari

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 accessfilef

try

set imageVersions to readfnusing delimiter ","

on error number -39

close accessfn

end try


close accessfn


tell application "Aperture"

tell library 1

makenewalbumwith properties {name:newAlbum}


set aa to (every image version)

repeat with i in aa

if name of i is in imageVersions then

try

duplicateitoalbumnewAlbum

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

Applescript for Making album from filename in text/clipboard

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.