Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Question:

Question: Find keywords without photos?

I know of and have used Léonie's script to find photos without keywords.


I'm looking for the opposite -- find (and optionally delete) all keywords which are not in use - that is, all the keywords for which there are no photos.

MacBook Pro with Retina display, OS X Yosemite (10.10)

Posted on

Reply
Question marked as Helpful

Apr 23, 2018 6:47 AM in response to Daniel M. Drucker In response to Daniel M. Drucker

Launch Script Editor.

Then go to the File menu, select "File > Open Dictionary". Then select the Photos.app.


The dictionary for Photos will show you, which scripting commands and classes the Photos.app understands.


User uploaded file

There’s more to the conversation

Read all replies

Page content loaded

Apr 23, 2018 3:08 AM in response to Daniel M. Drucker In response to Daniel M. Drucker

The Keyword Manager will tell you, if a Keyword is used for any photo, when you try to delete a keyword.


Try the following:

- open the Keyword Manager and click "edit" at the bottom of the Keyword manager.

- click a keyword that you rarely use and delete it.

If the keyword is assigned to an item you will get a warning, that the keyword is in use by xxx items. then leave it alone and test the next keyword.

Apr 23, 2018 3:08 AM

Reply Helpful

Apr 23, 2018 6:33 AM in response to Daniel M. Drucker In response to Daniel M. Drucker

There is no built-in search for unused keywords. You could program a script, that searches for keywords, that are not applied to any item, or just ignore the unused keywords.


If you are using iCloud Photo Library, and all photos are in iCloud, you can get rid of all unused keywords, by deleting your Photos Library and downloading it again from iCloud to a new, empty library. Unused keywords do not sync to iCloud, so only keywords assigned to some media item will sync back from iCloud to the new library. But the drawback would be, that your projects would also be lost. So you have to keep a copy of your current library on an external drive to save your projects.

Apr 23, 2018 6:33 AM

Reply Helpful
Question marked as Helpful

Apr 23, 2018 6:47 AM in response to Daniel M. Drucker In response to Daniel M. Drucker

Launch Script Editor.

Then go to the File menu, select "File > Open Dictionary". Then select the Photos.app.


The dictionary for Photos will show you, which scripting commands and classes the Photos.app understands.


User uploaded file

Apr 23, 2018 6:47 AM

Reply Helpful (1)

Apr 23, 2018 3:31 PM in response to léonie In response to léonie

So I've looked through the dictionary, and I'm not seeing any way to iterate over keywords. Have I missed something? I see how to retrieve the keywords for a media item, but not how to retrieve the list of keywords (whether associated or not).


Have I missed something, or is this not possible?

Apr 23, 2018 3:31 PM

Reply Helpful

Apr 24, 2018 4:20 AM in response to Daniel M. Drucker In response to Daniel M. Drucker

You can find all keywords assigned to any photo, if you irate about all media items in the library.

This snippet of code will collect a list of all used keywords:


tell application "Photos"

set usedKeys to {" "}

set theItems to its media item as list

repeat with im in theItems

tell im

set kws to its keywords as list

if (exists kws) and kws is not {missing value} then

set usedKeys to kws & usedKeys

end if

end tell

end repeat

end tell

return usedKeys


To make it more convenient you could sort this list alphabetically and weed out duplicates.


But there seems to be no way to have AppleScript show all keywords stored in the library, including unused keywords.

The list of keywords from the keyword Manager cannot be copied to a textfile, as I had hoped.


I found a simpler work-around, without scripting.


You can simply select the Photos view in Photos and select all photos at once with ⌘A.

Then open the Keyword Manager.

All used keywords will be highlighted in blue, the unused keywords are white. Take a screenshot.


Then you can use the "Edit keywords" command to delete the unused keywords. For example - I selected all photos in the library. All keywords in blue are used by some photos, the others are not in use.

User uploaded file

Apr 24, 2018 4:20 AM

Reply Helpful
User profile for user: Daniel M. Drucker

Question: Find keywords without photos?