News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Removal of matching keywords with a single command

Started by irinaonline, February 15, 2019, 04:30:00 PM

Previous topic - Next topic

irinaonline

Is it possible with a single command to remove all keywords matching a criteria?

Example: I have the keywords "a", "b", "c", "aa", "ab", "ac", "aaa" , "aab", "aac" and want remove the keywords "aa", "aaa", "aab" and "aac" with something like "-Keywords-=aa*"

Phil Harvey

There are probably other ways to do this, but this is the first thing that comes to mind:

exiftool "-keywords<${keywords@;$_=undef if /^aa/}" -sep "--" DIR

I haven't tested this to be sure it works, but I think it should do the job.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

irinaonline

I will test it, thank you.

Is there any difference in the syntax, if the keywords include spaces?

In my example, I want delete all keywords with "Last Version from ..."

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

irinaonline

Somehow it does not work. I created 4 keywords with acdsee and ran the command with the hardcoded search string 200. It worked. Then I changed it the search string to a variable and wanted remove the 201's but this did not work. Then I tried to hardcode the 201 and it as well did not remove them. I check the tags via acdsee. Maybe the keywords are written into different areas when they were created via acdsee?

StarGeek

What is your exact command?  It helps to see it so we can determine exactly what is wrong.

Phil's example assumes that "aa" was at the start of the keyword, as per your example.  If you're looking for a value that's not at the start, then the command would be different.  The command uses Regular Expressions (RegEx) so if you're unfamiliar with them, it might take some research.   

As for the possibility that ACDsee puts it some place else,  it's quite possible.  See FAQ #3.  Other possibilities include Subject and HierarchicalSubject.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

irinaonline

A tag of the actual batch version is written once, as the version of the batch changes.

A picture shall be filtered out from a batch if it has already a tag of the actual version.

With writing the actual version, all previous version tags shall be removed.

Example: my actual version tag is "WorkflowVersion Pro 2019.0014"

%PET%%FAST%%REC%%OWO%%EXT% -sep ", " -charset filename=utf8 -Keywords-="WorkflowVersion %sProjectShort%,WorkflowVersion %sProjectMedium%" -Keywords+="WorkflowVersion %sProjectShort%,WorkflowVersion %sProjectMedium%" -if "(not $keywords =~ /WorkFlowYes/i) and (not $keywords =~ /WorkflowVersion %sProjectShort%/i) and ($filename =~ /%DTYPE%%L%/i) and (not $filename =~ /Testphoto/i) and ($filetype =~ /JPEG/i)" "%PINBOXTEMP%"

I would like to add to this command the removal of all previous versions with something like "WorkflowVersion*"





Hayo Baan

Something like
exiftool "-keywords<${keywords@;$_=undef if /^WorkflowVersion/}" -sep "--" DIR
should work to remove all keywords with WorkflowVersion at the start.

If that doesn't work, can you sow the output of exiftool -keywords ?

Also make note of StarGeek's comment on the other candidates for keywords.
Hayo Baan – Photography
Web: www.hayobaan.nl