Looks like no one’s replied in a while. To start the conversation again, simply ask a new 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 Apr 22, 2018 6:23 PM

Reply
Question marked as Best reply

Posted on Apr 23, 2018 6:47 AM

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

7 replies

Apr 24, 2018 4:20 AM 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 23, 2018 3:08 AM 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 6:33 AM 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.

Find keywords without photos?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.