Created
November 9, 2023 12:56
-
-
Save paschmann/536def178ea9dd96c22c2143cc2b212c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Photos" | |
activate | |
set folderList to name of every folder | |
set selectedFolders to choose from list folderList with prompt "Select folders:" with multiple selections allowed | |
set destination to POSIX path of (choose folder with prompt "Please select a backup location:") | |
repeat with f in folders | |
if selectedFolders contains name of f then | |
my exportFolder(f, destination, name) | |
end if | |
end repeat | |
end tell | |
-- export a folder to a given destination | |
on exportFolder(tFolder, tPath, name) | |
set folderName to tPath & "/" & name | |
log folderName | |
using terms from application "Photos" | |
tell tFolder | |
repeat with childAlbum in albums | |
my exportAlbum(childAlbum, folderName) | |
end repeat | |
repeat with childFolder in folders | |
set name to name of childFolder | |
my exportFolder(childFolder, folderName, name) | |
end repeat | |
end tell | |
end using terms from | |
end exportFolder | |
-- export an album to a given destination | |
on exportAlbum(tAlbum, tPath) | |
set alName to name of tAlbum | |
set albumName to tPath & "/" & alName | |
my makeFolder(albumName) | |
log albumName | |
tell application "Photos" | |
try | |
with timeout of 30 * 60 seconds | |
export (get media items of tAlbum) to (albumName as POSIX file) with using originals | |
end timeout | |
on error | |
tell me to delay 5 | |
activate | |
with timeout of 30 * 60 seconds | |
export (get media items of tAlbum) to (albumName as POSIX file) with using originals | |
end timeout | |
end try | |
end tell | |
end exportAlbum | |
on makeFolder(tPath) | |
do shell script "mkdir -p " & quoted form of tPath | |
end makeFolder |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment