batch import on iPhoto

user blend3 has been super helpful in helping me put together an app which imports images into iphoto from a selected folder (including nested folders)… But now I have a new challenge…Is there anyway to do it so it does a batch import instead of one at a time which is triggering a new event in iphoto each time?

this is the script :



global main_folder

on run
	display dialog "Select your folder in the next menu" buttons {"Cancel", "Ok"} default button 2
	set main_folder to choose folder
end run

on idle
	
	tell application "Finder"
		set folder_list to every folder in entire contents of main_folder
		
		repeat with this_folder in folder_list
			
			set file_list to every file of this_folder
			repeat with this_file in file_list
				set this_file to this_file as alias
				tell application "iPhoto"
					if file type of this_file is "JPG" or file type of this_file is "JPEG" then
						import from this_file
						delay 5 -- wait for import to finish
						tell (the first album whose name is "Last Import") to select photos
						assign keyword string "Eye-fi"
						select (the first album whose name is "Eye-fi")
					end if
				end tell
				delete this_file
			end repeat
		end repeat
	end tell
end idle


Model: powerbook g4
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Susan:

You should be able to fix that in your iPhoto Preferences. Open it up, select Events, and toward the bottom you will see both the AutoSplit into Events drop down list and the checkbox for Finder imports. Select the Autosplit preference, and check the box. That should do it.

Hi Susan,
If for any reason you have any problems or choose not to use Craigs suggestion then have a look at this!
I’ve be playing with the script I posted, and using the code below you should be able to search every folder and make a list of all of the pics in those folders and then import them all in one go.

global main_folder

--on run
set main_folder to choose folder
--end run

--on idle
tell application "Finder"
	set folder_list to every folder in entire contents of main_folder
	set total_files to {}
	repeat with this_folder in folder_list
		set file_list to every file of this_folder
		set this_folder_import_list to {}
		repeat with this_file in file_list
			set this_file to this_file as alias
			set this_folder_import_list to this_folder_import_list & this_file
		end repeat
		set total_files to total_files & this_folder_import_list
	end repeat
	tell application "iPhoto"
		import from total_files
		delay 30 -- wait for import to finish
		tell (the first album whose name is "Last Import") to select photos
		assign keyword string "Eye-fi"
		select (the first album whose name is "Eye-fi")
	end tell
	repeat with this_pic in total_files
		delete this_pic
	end repeat
end tell
--end idle

For the moment I’ve commented out the run and idle handlers so that you can test this from Script Editor. Not sure how many pics you’re going to import in one go so I’ve changed the delay time.
Hope this helps,
Nik

Hi,

iPhoto has a property importing which is more elegant than just a delay command


.
	tell application "iPhoto"
		import from total_files
		repeat while importing
			delay 1
		end repeat
.

StefanK - do you know if the iphoto property “importing” is new to the latest iPhoto? I have an older version and am getting a “The variable importing is not defined” error.

I’m afraid this could be. I have no iPhoto 6 version installed to verify it.
Then you must take the delay line