Importing Files to iPhoto 6 via applescript

Ok, if you’ve followed my other thread, I’ve successfully gotten a folder action to rename all downloaded pictures and move them to a seperate folder. I’m trying to get that other folder to automatically import the pictures to iphoto and then delete them. I’m stuck on the import part; it just doesnt seem to work. Here’s what I have so far:

on adding folder items to this_folder after receiving saved_itmes
	tell application "iPhoto"
		activate
		import files from "Macintosh HD:Users:myname:Desktop:Downloads:Pictures:"
	end tell
end adding folder items to

That manages to open iphoto and thats about it. I’m using iPhoto 6.0.2 if that helps any. Thanks in advance!

Thanks! Now how do I get finder to delete the files after importing them. Correction: I got it to delete, but it deletes too fast. How do I delete the files only after they are done importing? Here’s the script so far:

on adding folder items to this_folder after receiving saved_itmes
	tell application "iPhoto"
		activate
		import from alias "Macintosh HD:Users:myname:Desktop:Downloads:Pictures:"
	end tell
        Delay x
	tell application "Finder"
		delete files of alias"Macintosh HD:Users:myname:Desktop:Downloads:Pictures:"
	end tell
end adding folder items to

Edit: I found the delay command… I tried 15 seconds and it seemed to work in this case. Is there a better way to do this? I may set the delay for much longer as there may be a large picture or many pictures to import at once.

Thanks Jacques! I’ve settled on slightly less autonomous solution of renaming all the files on download and moving to another holding folder. Then I can move all the files at once to an import folder. That way I can set it to import and then delay 10min or whatever before deleting the files. Whereas before, importing them on the fly, invariably another file would get added to the folder before the previous files deleted. Then it would try to import all the files over again, etc. Its been a fun learning project, and it will definitely be more efficient than doing everything by hand. If it gives me more trouble I’ll give your repeat loop a try. Thanks again!

edit: I also made use of the this_folder reference in the top to replace both long path aliases.

-Chris