Here’s the one:
That’s probably it!
gl,
kel
Here’s the one:
That’s probably it!
gl,
kel
So, it would go something like this:
remove every item from (a reference to the album).
In the case you’re wondering how I found that was to look in the dictionary of Photos.
gl and happy scripting,
kel
Tell me if that was it. Otherwise, there might be a little more to it.
Edited: you never know.
Edited: the reason why I say this is I don’t have much time. I would have to create a new album and test on that. But, I’m washing clothes! and hopefully can rest after that.
gl,
kel
Hi Poleary,
Did you get it to work?
Now I have some time and was thinking about trying out the ‘remove’ with the filter reference form. The part I didn’t like was removing every photo from an album. So, I have to crate a whole new small album and didn’t have time.
I’ll show you a good example if I can think of one.
Edited: btw, not sure but it read like you knew about AppleScript so I was very vague.
Later,
kel
Ok, what I was thinking is that say you have an album selected. So, what you want to do is remove every photo from that album. The selection doesn’t seem to cover albums. so, you need to somehow get your script to select an album.
I got it! You choose the album from the list or another way way might be to select a photo from an album and from there get the album. I kind of like the idea of selecting an album to delete items. Sounds good to me.
Edited: Ooo, It’s a little bit trickey. Nice puzzle.
Later,
kel
I’m starting to think that the best way to do this is to go back to the original idea of deleting the album and creating a new album. Interesting though. What if I just wanted to delete every photo but the last one.
Darn, I can’t find the remove command. It must have been from iPhoto. Ok, damn it. Gotta get serious here…
Ok, think I found the secret. This reminds me of Mail when ti first came out. It seems the programmers don’t know about AppleScript very much.
I got it! Why the hell did they use container instead of album? Crazy man.
Darn, I remember now. Had to delete it from the database. Darn! That’s why I was asking how to delete items from the database. I think. Yeah, I think that was it. I remember something about sqlite or something like that.
The way Apple has it now, you can’t even hack your own computer!
Darn, I think you have to resort to uielement scripting to get rid of the photos. It’s too bad because all you would actually need to do is delete it from the database, if.
gl,
kel
In the olden days you might find that database and make changes, but now days you might just as well wait and perhaps send in some feedback to Apple.
gl,
kel
Here’s as far as I got and then you need to search trough the database I think:
tell application "Photos"
set the_album to first container whose name is "TestAlbum1"
every media item of the_album
end tell
From there you need to find the database and modify it. And then you don;t know if that will even work I think.
gl,
kel
Hi there,
THANK YOU so much for your help. I wasn’t able to test it yet. Prior to your help, I got fed up with the speed of Photos on OS X. It was choking on my 60k picture library. I literally couldn’t do anything without it giving me the beachball of death.
I will definitely save this and use / try it out once I test it again under OS X El Capitain.
Thanks again, and sorry for the delay responding!
Hi poleary,
Actually, there is no solution as I remember. Maybe in the future there might be one.
gl,
kel
I’m trying to remove all the photos from an album but I can’t seem to find “remove” in the dictionary. I see “delete” but that is only for albums and folders.
I tried:
set target_album to album named target_album_name of container target_folder_name
repeat with photo in media items in target_album
remove photo
end repeat
Any thoughts? For now I am deleting the album and recreated. However i would prefer just to remove the media items.
tell application "Photos"
activate
set thePhotos to media item of album "Alexandra"
repeat with thePhoto in thePhotos
spotlight thePhoto
delay 1
tell application "System Events"
tell application process "Photos"
click menu bar item "Image" of menu bar 1
try
click menu item "Delete 1 Photo" of menu 1 of menu bar item "Image" of menu bar 1
on error
click menu item "Remove 1 Photo from album" of menu 1 of menu bar item "Image" of menu bar 1
end try
repeat while (sheet 1 of window 1 exists)
delay 0.1
end repeat
end tell
end tell
end repeat
end tell
NOTE: you can filter deleted photos with some criteria.
The following script automatically deletes all photos whose name contains “1”, without confirmation:
tell application "Photos"
activate
set thePhotos to media item of album "Alexandra"
repeat with thePhoto in thePhotos
if name of thePhoto contains "1" then
spotlight thePhoto
delay 1
tell application "System Events"
tell application process "Photos"
click menu bar item "Image" of menu bar 1
try
click menu item "Delete 1 Photo" of menu 1 of menu bar item "Image" of menu bar 1
on error
click menu item "Remove 1 Photo from album" of menu 1 of menu bar item "Image" of menu bar 1
end try
end tell
delay 0.5
keystroke return
end tell
end if
end repeat
end tell
The Last NOTE: The deleted photos goes to the folder “Recently Deleted”. This is a trash of Photos app. To permanently empty this trash you should add to end of the scripts above that:
tell application "System Events" to tell application process "Photos"
click static text 1 of UI element 1 of row 8 of outline 1 of scroll area 1 of splitter group 1 of window 1
repeat until (window 1 exists)
delay 0.1
end repeat
click UI element "Delete All" of group 1 of splitter group 1 of window 1
delay 0.5
click UI element "OK" of sheet 1 of window 1
end tell