I have a separate Photo library for . For simplicity let's call them
Personal (the main iCloud one)
Business
When I take a screenshot I want it to be uploaded to Business and I want to add keywords to the photos at the time of taking the screenshot.
PowerPhotos allows me to upload to different libraries via AppleScript
tell application "PowerPhotos"
import myFileList into library "Other Library"
end tell
but I need to organise a way of adding the keywords at the time of the screenshot.
I think it's possible to do this using AppleScript but I'm stuck at the part where I get KM to pop up a list of pre-populated keywords. Is this possible?
I think I can
tell eachImage to set exifDate to "
but that's as far as I get.
Can anyone help?
Perhaps this can be better done or combined with BetterTouchTool or Alfred. I have a hard time with all the ways to skin these cats.
PowerPhotos isn't going to do anything with the exif data. I was just going to use it because it can add stuff to the library without actually opening the library.
And, also, I can tell it which library to add to; not the main one.
Hi @James_Veitch - apart from the essential advice given by @Nige_S I'd suggest the following:
Assemble the arguments for your shell command in a KM variable first. For example, Set Variable FOO to the text %Variable%SELECTEDKEYWORDS%" %Variable%IMAGEFILEPATH%
That way you can examine what you're passing to the command line (FOO) using a Display Text action and quickly see if it is as you expected or not.
I'm assuming that SELECTEDKEYWORDS and IMAGEFILEPATH are variables of yours; notice I use the standard way to reference variables: %Variable%xxx% which avoids confusing them with KM Tokens and simplifies debugging. I never reference variables any other way, even though it is legal and most experienced KM users do the same.
Whenever anyone uses a shell command there are always problems regarding (a) the shell search path since the KM shell is not the same as the Terminal shell, (b) escaping/quoting arguments. The page linked to by @Nige_S provides some information regarding that but there are numerous threads in this forum about it, so if you run into trouble you would do well to search around a bit! Pay particular attention to the KM variable ENV_PATH.
Anyway - let us know how you get on and if you need more help.
Do you reckon there will ever be something like Doug’s iTunes Scripts but for Photos Libraries?
I really want to automate moving photos between libraries. For instance, screenshots. I want them all out of my regular library. Particular keywords etc.
Oh - I didn't know about that until you mentioned it! So I just googled "AppleScript for Photos" which revealed a link to Photos Utilities Script Library which might give you a leg up.
I think part of the problem is that I’m not great at scripting. I was hoping for shortcuts. I also think that most of the scripts assume you have one photos library so the idea of opening one, taking photos from it, quitting it, opening another, importing photos to it is alien.
Incidentally, I think there are times when the Mac does just add photos to photos.app library without actually opening it. Do you know how it achieves this? I notice that even though PowerPhotos doesn’t need to open App to access the libraries, it can’t keep two open at once; or doesn’t appear to.
Hi @James_Veitch,
I just did a little test with this AppleScript:
tell application "Photos"
set theDestinationAlbum to first container whose name is "Test"
set selectedItems to selection
add selectedItems to theDestinationAlbum
end tell
I created an album called "Test" in Photos
I went to another album and selected a few photos
I ran the above script (in Script Debugger) but the Script Editor app would also do
I looked in the Test album and the selected photos had been added to it
There doesn't seem to be a way of deleting photos from an album using AppleScript so I would use the Photos menu item to remove the selected images from the source album in order to "complete" the move operation.
I think it would not be too hard to parcel all this up into a KM macro.
Oh - I've just realised you were asking about "libraries". Did you actually mean "albums"? If not, what is a "library"?
Macros are always disabled when imported into the Keyboard Maestro Editor.
The user must ensure the macro is enabled.
The user must also ensure the macro's parent macro-group is enabled.
System Information
macOS 10.14.6
Keyboard Maestro v10.2
The destination album is set in the red-coloured action. You can hard code it in to suit you or have a Prompt for User Input to set it. Or some other means - whatever you like. If you set it to an album that doesn't exist, the macro will fail and show an error message.
Running the macro without first selecting at least one item from another album will prevent the macro from doing anything at all except to display a message telling you to select something first!
Otherwise the macro copies the selected items to the destination album and then deletes those items from the source album.
If you play with this please make test copies of your images and albums before trying this out in case something goes wrong!
Thanks so much again.
The problem is moving photos between libraries though. Not albums.
I think I can do albums simply by using smart albums and adding tags.