Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kjoglum

macrumors newbie
Original poster
Oct 7, 2014
1
0
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?
 
Last edited by a moderator:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.