Exporting Apple Photos Albums to Folders

I have an Apple Photos library with ~8000 scanned photos. I have named each photo such that it corresponds to a physical folder that contains the original paper photo. I have placed every photo into Apple Photos albums. Each photo is assigned to 1 album. I have 100+ albums. I want to export all of the photos into folders named by album while maintaining the original file names. Anyone know of a method to do this other than manually, album by album?

AppleScript and/or Automator could do this.

1 Like

AppleScript. I bookmarked this site some time ago for use in a similr project:

1 Like

Thanks @jec0047 and @Medievalist I’m not proficient with either AppleScript nor Automator but I’ll take a look. :stuck_out_tongue_winking_eye:

I think I found a possible solution. I need to test it out before I post a link here. Thank you all for setting me on the correct path.

1 Like

Solution: Found a script by Jacques Rioux in the Apple Support Community to export Apple Photos albums to folders. Export Albums to Folders - Jacques Rioux'… - Apple Community

To run the script below, change HOME in the first line to the name of your user folder.
This is his script with the addition of 2 lines of code to prevent a timeout error. Default timeout as his original script was written was 2 minutes so if you had a large number of albums to export it probably would timeout. If you want a timeout you can you can change from 0 seconds to however many seconds you want before timeout. I have no idea if avoiding a timeout error is good practice or not (maybe there is a reason for timeouts) - I am not a coder but I’m semi almost kinda good at copying scripts.

set dest to "/Users/HOME/Desktop/PHOTOS-Albums/" as POSIX file as text -- the destination folder (use a valid path) 
tell application "Photos"
	activate
	set l to name of albums
	set albNames to choose from list l with prompt "Select some albums" with multiple selections allowed
	
	if albNames is not false then -- not cancelled  
		repeat with tName in albNames
			set tFolder to dest & tName
			my makeFolder(tFolder) -- create a folder named (the name of this album) in dest
			with timeout of 0 seconds -- avoid the timeout error   
				export (get media items of album tName) to (tFolder as alias) without using originals
			end timeout
		end repeat
	end if
end tell

on makeFolder(tPath)
	do shell script "mkdir -p " & quoted form of POSIX path of tPath
end makeFolder
1 Like

So… will this still work?

Don’t know. It worked fine for me in Aug 2022. :grinning:

1 Like

I just tried the one I posted above and it seems to still work.

1 Like

This worked great, thank you! But why does it change the original date to a couple of days ahead once the picture is exported?

Her’s a tool that I have bookmarked for future use. You might want to look it over…

2 Likes

I don’t know the answer to this. I have not checked to see if this happened when I used this script.