Is There a Way of Saving a Screenshot with a Keyword Added to Its Exif Meta Data?

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.

Any help greatly appreciated.

You can use a Prompt With List action for that. Here's an example:
Test Keyword List.kmmacros (2.1 KB)

Click to see macro

Keyboard Maestro Export

Notice that the options for the Prompt action (under the gear menu) include allowing multiple selections.

I would use exiftool to manipulate EXIF metadata but if PowerPhotos allows that then fine.

Try searching this forum for "exif" to see what other users have done.

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.

Thanks for this!

1 Like

@tiffle so I've managed to get Exiftool to add keywords to photos using terminal.

I'm a bit stuck now though because I'm not entirely sure how to go about putting the variables in a shell script.

See this bit of the "Execute Shell Script" wiki page.

Hi @James_Veitch - apart from the essential advice given by @Nige_S I'd suggest the following:

  1. Assemble the arguments for your shell command in a KM variable first. For example, Set Variable FOO to the text
    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.
  2. 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.
  3. 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.

Thanks so much for this @Nige_S and @tiffle.

I'm experimenting right now and reading that wiki.

1 Like

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.

Any good for you?

Yeah I checked that out. But it’s woefully outdated so I’m reticent to even begin. One of the tabs is “iWork automation”

Sure, but that's a completely separate website.

Well maybe I’ll give it a go.

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 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.

)thanks btw)

1 Like

That's my problem too when it comes to AppleScript.

Most of my AppleScript comes from this forum and google searches :man_shrugging:

Check this out: Applescript to add image to album - AppleScript - Automators Talk

The first and 3rd posts might help you out...

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
  1. I created an album called "Test" in Photos
  2. I went to another album and selected a few photos
  3. I ran the above script (in Script Debugger) but the Script Editor app would also do
  4. 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"?

EDIT: see next post for a macro.

Hi @James_Veitch - as time is pressing I've knocked up a demo macro for you that is a starting point for you. Here it is:

Download Macro(s): Test Move Photos Between Albums.kmmacros (5.5 KB)


Keyboard Maestro Export

  • 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!

WOW I'm so sorry I didn't reply to this/ Had a lot on my mind and didn't get to it until just now. Thank you so much for this. Will report back.

1 Like

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.

OK - but as I said previously

Sorry - I hardly ever use Photos!