Author Topic: Removal of matching keywords with a single command  (Read 223 times)

irinaonline

  • Full Member
  • ***
  • Posts: 30
Removal of matching keywords with a single command
« 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*"

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14733
    • ExifTool Home Page
Re: Removal of matching keywords with a single command
« Reply #1 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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

irinaonline

  • Full Member
  • ***
  • Posts: 30
Re: Removal of matching keywords with a single command
« Reply #2 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 ..."

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14733
    • ExifTool Home Page
Re: Removal of matching keywords with a single command
« Reply #3 on: February 15, 2019, 05:01:34 PM »
Same syntax
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

irinaonline

  • Full Member
  • ***
  • Posts: 30
Re: Removal of matching keywords with a single command
« Reply #4 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?

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2514
Re: Removal of matching keywords with a single command
« Reply #5 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.  Other possibilities include Subject and HierarchicalSubject.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

irinaonline

  • Full Member
  • ***
  • Posts: 30
Re: Removal of matching keywords with a single command
« Reply #6 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*"





Hayo Baan

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 1046
  • Professional Photographer & Software Developer
    • Hayo Baan – Photography
Re: Removal of matching keywords with a single command
« Reply #7 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.
Hayo Baan – Photography
Web: www.hayobaan.nl