Photos - removing an image from an Album


I’m trying to write a script to “move” an image from one Album to another. This is part of a bigger “thing” where I export an image, re-size it and import it in to Microsoft Word. That bit is working, now I wanted to finish things up, by moving the images processed out of the current album and into a another to get it “out of the way” so to speak.

I issue is I can’t find any way to remove an image from n album. Did I miss something, or did Apple simply “forget” to implement such a basic method (if you can ADD you should be able to “REMOVE”)

Here’s my script:

-- Move an image to another folder, containg an album with the same name (with extension, e.g. "_Moved")
set myAlbum to GetCurrentAlbumName(0) as string
log "Currently selected album: " & myAlbum

tell application "Photos"
	set listSelectedPhotos to (get selection)
	set myImage to first item of listSelectedPhotos
	log "Currently selected image: " & name of myImage as text
end tell

set {myDoneFolder, myDoneAlbum} to CreateAlbum(myAlbum)
log "Folder for processed albums: " & myDoneFolder
log "Album for moved images: " & myDoneAlbum

tell application "Photos"
	-- set oldAlbum to container myAlbum -- mmmmmm
	set NewFolder to container myDoneFolder
	set NewAlbum to container myDoneAlbum of container myDoneFolder
	add {myImage} to NewAlbum
	-- This is where I got stuck .... how can I remove "myImage" from the Album "myAlbum"
	-- I can't find any reference to a remove 
	-- remove {myImage} from container oldAlbum
end tell

on CreateAlbum(newAlbumName)
	-- Define the names of the Folder and Album to move processed images to
	set DoneFolderName to "ImagesMoved" as string
	set myAlbumName to newAlbumName & "_Moved" as string
	tell application "Photos"
		-- Make sure a folder exists where all the "Moved" albums will be created
		if exists container DoneFolderName then
			set doneFolder to container DoneFolderName
			set doneFolder to make new folder named DoneFolderName
		end if
		-- Create an Album for the images already moved, to get them out of the way
		if not (exists container myAlbumName of container DoneFolderName) then
			set theAlbum to make new album named myAlbumName at doneFolder
		end if
	end tell
	return {DoneFolderName, myAlbumName}
end CreateAlbum

on GetCurrentAlbumName(dummy)
	-- Logic borrowed from
	tell application "Photos" to activate
	tell application "System Events"
		tell process "Photos"
			tell outline 1 of scroll area 1 of group 2 of splitter group 1 of window 1
				if (rows whose selected is true) is {} then return
				set theSelectedRow to row 1 whose selected is true
			end tell
			tell UI element 1 of theSelectedRow
				if name is not missing value then -- All Photos / Faces / Last Import
					set theSelectedAlbumName to name
				else -- My Albums
					set theSelectedAlbumName to value of text field 1
				end if
			end tell
		end tell
	end tell
	-- log theSelectedAlbumName
	return theSelectedAlbumName
end GetCurrentAlbumName

Any help / hints would be greatly appriciated


See the answer HERE