iPhoto 09: Rename Photo with the name of the album its in.

I am trying to find a script that when I select all of my Albums in iPhoto 09 it will rename all the photos to the name of the album it is currently in, plus add a space, a dash and another space. For Example

Album Name is “Family” it will change the name of all the photos in that album to: Family -

Any help with this would rock.

Thanks

Hi,

try this, select one or multiple albums and run the script. The script aborts if only photos are selected.
As many files will be renamed, please test the script with a copy of your library or with a small album.


tell application "iPhoto"
	set selectedAlbums to selection
	if class of item 1 of selectedAlbums is album then
		repeat with oneAlbum in selectedAlbums
			set albumName to name of oneAlbum
			repeat with aPhoto in (get photos of oneAlbum)
				set name of contents of aPhoto to albumName & " - " & (get name of aPhoto)
			end repeat
		end repeat
	end if
end tell


Note: Consider if a photo is in more than one album you might get unexpected behavior by a chain of album names

Almost there, I need it to replace the name of the Photos.

Example: Photos name is DC12543.jpg
when I run the script it should replace DC12543.jpg with Family - or whatever the album name is.

Thanks.

Really? Then you have a bunch of photos with the same name.
remove
& (get name of aPhoto)
to get this behavior

And again: If a photo is in album Family and in Holidays, the photo will be renamed with the album name
of the last occurrence.

Thanks, this works perfectly. True I will have all the same names but I have to go back in and manually type the descriptions after the dash.