ExifTool Forum

ExifTool => Newbies => Topic started by: irinaonline on February 15, 2019, 04:30:00 PM

Title: Removal of matching keywords with a single command
Post by: irinaonline on February 15, 2019, 04:30:00 PM
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*"
Title: Re: Removal of matching keywords with a single command
Post by: Phil Harvey on February 15, 2019, 04:45:40 PM
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
Title: Re: Removal of matching keywords with a single command
Post by: irinaonline on February 15, 2019, 04:53:13 PM
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 ..."
Title: Re: Removal of matching keywords with a single command
Post by: Phil Harvey on February 15, 2019, 05:01:34 PM
Same syntax
Title: Re: Removal of matching keywords with a single command
Post by: irinaonline on February 15, 2019, 05:27:41 PM
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?
Title: Re: Removal of matching keywords with a single command
Post by: StarGeek on February 15, 2019, 05:48:10 PM
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 (https://exiftool.org/faq.html#Q3).  Other possibilities include Subject and HierarchicalSubject.
Title: Re: Removal of matching keywords with a single command
Post by: irinaonline on February 15, 2019, 08:04:35 PM
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*"




Title: Re: Removal of matching keywords with a single command
Post by: Hayo Baan on February 16, 2019, 05:17:42 AM
Something like
Code: [Select]
exiftool "-keywords<${keywords@;$_=undef if /^WorkflowVersion/}" -sep "--" DIRshould 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.