Applescript, import img to iPhoto

Discussion in 'Mac Programming' started by Gaff, May 14, 2008.

  1. Gaff macrumors newbie

    Joined:
    May 14, 2008
    #1
    Hi, I've been trying to put together a script that will import only images to iPhoto.

    I have no previous programming experience, I just put this together by pieces I found when I searched for a script like this.

    I have a folder I drop random things into, say it's a download folder. I want to attach a folder action to it, that will import _only_ images into iPhoto, and afterwards delete the image. I want it to import only images, because I drop other things into it as well.

    This is what I got, but it doesn't work. I was hoping someone more knowledgeable could tell me what's wrong with it. I apologize if it looks silly or stupid, but I just tried to think logically when I put it together. As I said, I'm not a programmer. Anyway, here it is:
    Code:
    on adding folder items to this_folder after receiving added_items
    	if the name of aFile contains {".jpg"} ¬
    		or the name of aFile contains {".gif"} ¬
    		or the name of aFile contains {".png"} ¬
    		or the name of aFile contains {".pict"} ¬
    		or the name of aFile contains {".tiff"} ¬
    		or the name of aFile contains {".gif"} ¬
    		or the name of aFile contains {".psd"} ¬
    		or the name of aFile contains {".bmp"} then
    		tell application "iPhoto"
    			import from added_items to (the first album whose name is "New images")
    			delay 5
    			select (the first album whose name is "New images")
    		end tell
    		tell application "Finder" to delete added_items
    	end if
    end adding folder items to
    
     
  2. masterp34588 macrumors newbie

    Joined:
    Aug 11, 2008
    #2
    I've just discovered Shovebox today. I'm testing it out and my hopes are to have it automatically add any photos I drop onto the menubar icon to my iPhoto library and have a keyword attached. I have no applescript experience at all. This script about the closest thing I've seen after searching around for an hour. I attempted to use this script and I get a successful growl notification and a sound notification but I don't see the file in iPhoto. Is this possible (I imagine I will have to modify the script) and will it work with iPhoto '09?
     

Share This Page