Skip to content

Instantly share code, notes, and snippets.

@steveriggins
Created June 29, 2026 21:36
Show Gist options
  • Select an option

  • Save steveriggins/268ab95a4a7447c1a7cc800ac233e6e9 to your computer and use it in GitHub Desktop.

Select an option

Save steveriggins/268ab95a4a7447c1a7cc800ac233e6e9 to your computer and use it in GitHub Desktop.
AppleScript to delete many Photos Albums
-- ⚠️ DESTRUCTIVE APPLESCRIPT
-- ⚠️ IF THIS SCRIPT SCREWS UP YOUR PHOTOS ALBUMS, MY NAME IS GARY
-- ⚠️ YOU MUST UNCOMMENT THE DESTRUCTIVE LINE OF APPLESCRIPT YOURSELF
-- ⚠️ Change deleteAlbumsWhoseNameBeginsWith to the prefix of albums you want deleted
set deleteAlbumsWhoseNameBeginsWith to "REPLACE_THIS_AND_BE_CAREFUL"
tell application "Photos"
set ids to {}
repeat with thisOne in albums
if ((name of thisOne) as string) begins with deleteAlbumsWhoseNameBeginsWith then
-- Who doesn't love a good variable name
set foo to id of thisOne
copy foo to the end of ids
end if
end repeat
repeat with idToDelete in ids
-- Comment out the display dialog command if you want to YOLO
display dialog (name of album id idToDelete) as string
-- ⚠️ THERE BE PIRATES AHEAD!
-- ⚠️ BY UNCOMMENTING THIS LINE OF APPLESCRIPT, YOU FOREGO ALL RIGHTS TO LOWER RAM PRICES
-- delete album id idToDelete
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment