brock
1/23/2015 - 12:49 AM

Export all photos in iPhoto. You are prompted for the directory they will be copied into. The original files are copied, and they get copied

Export all photos in iPhoto. You are prompted for the directory they will be copied into. The original files are copied, and they get copied into individual folders for each date.

set destination to quoted form of POSIX path of (choose folder with prompt "Select the folder to create sub-folders and export photos")
tell application "iPhoto"
	set tc to count photos
	repeat with i from 1 to tc
		try
			tell photo i to my copyPhoto(date, image path, original path, title, destination)
		end try
	end repeat
end tell

on copyPhoto(d, p, origP, t, dest) -- the name of the file is the title of the photo in iPhoto, date format for folder name = 2014-09-25    
	tell d to set d to "" & its year & "-" & text -2 thru -1 of ("0" & ((its month) as integer)) & "-" & text -2 thru -1 of ("0" & its day)
	try -- create folder if necessary, check to not overwrite any files in the subfolder, copy the file, rename with the title    
		do shell script "f=" & d & ";t=" & (quoted form of t) & ";tFile=" & (quoted form of origP) & "; e=${tFile##*.}; cd " & dest & ";mkdir -p \"$f\"; while [ -e \"$f/$t.$e\" ];do  t=\"$t _\";done; cp -a \"$tFile\" \"$f/$t.$e\" && exit 0; cp -a " & (quoted form of p) & " \"$f/$t.$e\";echo 'test'"
	end try
end copyPhoto