Automator/Applescript alias error when importing pictures into Aperture

Discussion in 'Mac Programming' started by kjoglum, Oct 21, 2014.

  1. kjoglum, Oct 21, 2014
    Last edited by a moderator: Oct 21, 2014

    kjoglum macrumors newbie

    Joined:
    Oct 7, 2014
    #1
    Ok, I´m new to scripting, so please bear with me.

    So, I have an iMac with a pictures folder called ”Album” containing several subfolders with pictures. As per now, the folder ”Album” (with subfolders and pictures) are mirrored into Aperture using import as ”Projects and albums”. Thus, ”Album” is the project in Aperture, and the subfolders are albums, and the pictures within the albums are just referenced to the Finder folder local files (subfolder files).

    Now, the pictures folder ”Album” on my iMac is synced against a network drive at a weekly basis, whereas new subfolders with pictures and/or new pictures within existing subfolders might have been introduced. So what I´m aiming at is to use Automator/Applescript to automatically import new subfolders / pictures into the existing Aperture structure.

    However, with the Automator workflow / Applescript presented below, I receive an error message stating ”Can not get alias iMac HD:Users:Kjoglum:pictures:Album:Folder:File.extension”. Where Folder then is a subfolder within ”Album” and File.extension is a jpg picture.

    1. Get specified Finder items (target folder set to the Finder folder ”Album”)
    2. Get folder content (including subfolders)
    3. Filter Finder items
    - Kind is not folder
    - Date created last X days
    The output files from this task enters an Applescript

    Code:
    on run {input, parameters}
    	
    	repeat with f in input
    		
    		tell application "Finder"
    			set fileName to name of (f)
    			set parentFolder to name of container of (f)
    		end tell
    		
    		tell application "Aperture"
    			tell library 1
    				tell project "Album"
    					if (exists album parentFolder) then
    						set theProject to album parentFolder
    						import f by referencing into theProject
    						## Would like to include a code to only
    						## import file if not already existing
    					else if not (exists album parentFolder) then
    						set theProject to make new album with
                                                    properties {name: parentFolder}
    						import f by referencing into theProject
    					end if
    				end tell
    			end tell
    		end tell
    	end repeat
    	
    end run
    As mentioned above, I end up with an ”alias error” at the first import command.

    Any ideas/suggestions?
     
  2. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
    According to the Aperture_3_AppleScript_Reference images can only be imported into projects. You're trying to import into an album.

    Code:
    set [B]theProject[/B] to [COLOR="Red"]album[/COLOR] parentFolder
    import f by referencing into [B]theProject[/B]
     

Share This Page