Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'A script to trash an iPhoto Album and its images' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to trash an iPhoto Album and its images
Authored by: inblosam on Nov 16, '03 03:39:40PM
Hate to break it to you who spent so much time on that, but Apple has an applescript for doing the exact same thing, on their site even.
I have used this and it works.

HOWEVER...what I (and I assume others) really need is something that will delete all the images from an album, but not any that belong to another album. In a few cases I have pictures of my son in his album but the same picture in another album for our whole family. Granted I would still have the picture after using this, but it would be nice for it not to delete the image from the other album too. Anyone know how to do this??!!!??

Let me know if and when you do!

[ Reply to This | # ]
here you go
Authored by: SOX on Nov 17, '03 01:10:38AM
I have not tested this. use it at your own risk! but maybe this will give you the idea

tell application "iPhoto"
		set the album_list to the name of every album
		set this_ablum to (choose from list album_list with prompt "Pick the album to delete:") as string
		if this_ablum is "false" then error number -128
		display dialog "Are you sure you want to delete album "" & 
			this_ablum & "" and its contents?" & 
			return & return & 
			"This action cannot be undone." buttons {"Delete", "Stop"} default button 2 with icon 2
		if the button returned of the result is "Stop" then error number -128
		set the photo_count to the count of photos of album this_ablum
		if the photo_count is 0 then error "The chosen album contains no photos."
		set the ID_list to the id of every photo of every album
		with timeout of 1800 seconds
			repeat with i from the photo_count to 1 by -1
				set this_photo to photo i of this_album
				set this_ID to the id of this_photo --photo i
				set the add_flag to true
				repeat with q from 1 to the list_count
					set these_IDs to item q of the ID_list
					if these_IDs contains this_ID then
						set the add_flag to false
						exit repeat
					end if
				end repeat
				if the add_flag is true then
					add photo i of album this_ablum to trash album
				end if
			end repeat
			remove album this_ablum
		end timeout
		display dialog "The album "" & this_ablum & 
			"" has been deleted and its contents moved to the trash." & return & return & 
			"Choose "Empty Trash" from the iPhoto File menu to delete the images." buttons {"OK"} default button 1
	on error the error_message number the error_number
		if the error_number is not -128 then
			display dialog the error_message buttons {"Cancel"} default button 1
		end if
	end try
end tell

[ Reply to This | # ]