ExifTool Forum

ExifTool => Newbies => Topic started by: E_Rap on March 22, 2022, 02:27:37 PM

Title: How can I removed single quotation marks (ie 20's) from Keywords
Post by: E_Rap on March 22, 2022, 02:27:37 PM
I have inherited a large group of files.  Some of them have keywords like 20's or 80's... when I try to replace the single quotation mark I get an error message

exiftool "-keywords<${keywords;tr/"'"//d}"
Title: Re: How can I removed single quotation marks (ie 20's) from Keywords
Post by: StarGeek on March 22, 2022, 03:29:19 PM
Quote from: E_Rap on March 22, 2022, 02:27:37 PMexiftool "-keywords<${keywords;tr/"'"//d}"

Be careful with this, it makes Common Mistake #5b (https://exiftool.org/mistakes.html#M5).
     Adding a leading "$" when copying a simple tag ...  Also, values of list-type and shortcut tags are concatenated in the string rather than being copied individually

So this command would combine all keywords into a single keyword.

Try this
exiftool -api "Filter=s/'//g" -TagsFromFile @ -Keywords -Subject /path/to/files/

This uses the -api Filter option (https://exiftool.org/ExifTool.html#Filter) to use regex to remove single quotes.  It affects each keywords separately.
Title: Re: How can I removed single quotation marks (ie 20's) from Keywords
Post by: E_Rap on March 25, 2022, 04:18:33 PM
I have tried running this a few times but it does not eliminate the single quote.  Any other suggestions?

exiftool -api "Filter=s/'//g" -TagsFromFile @ -Keywords -Subject /path/to/files/
Title: Re: How can I removed single quotation marks (ie 20's) from Keywords
Post by: Phil Harvey on March 25, 2022, 09:36:33 PM
I'm on Mac, but StarGeek's command should work on any system:

> exiftool a.jpg -keywords
Keywords                        : Phil's, test
> exiftool a.jpg -api "Filter=s/'//g" -TagsFromFile @ -Keywords -Subject
    1 image files updated
> exiftool a.jpg -keywords
Keywords                        : Phils, test


- Phil
Title: Re: How can I removed single quotation marks (ie 20's) from Keywords
Post by: StarGeek on March 25, 2022, 10:00:28 PM
Run this command and copy/paste the output here
exiftool -G1 -a -s -Subject -Keywords file.jpg
Title: Re: How can I removed single quotation marks (ie 20's) from Keywords
Post by: E_Rap on March 26, 2022, 02:07:41 PM
First thank you for all the help received so far, this forum is really great!

I am still trying to remove single quotes from keywords:
   using a Windows 10 x64 workstation
   using exiftool ver 12.28

From Adobe Bridge the view looks like this:
1) Before any exiftool commands are run (Single Quote 1.jpg) screenshot
2) After using exiftool with the following command, exiftool -api "Filter=s/'//g" -TagsFromFile @ -Keywords -Subject -overwrite_original "Path\File" (please see Single Quote -2.jpg
3) After using exiftool with the following command, exiftool -G1 -a -s -Subject -Keywords "Path\File" (please see Single Quote - 3.jpg)
4) View from Command Prompt after both options have been tried (Please see Single Quote -4.jpg)
Title: Re: How can I removed single quotation marks (ie 20's) from Keywords
Post by: StarGeek on March 26, 2022, 05:40:44 PM
Those aren't single quotes ', those are fancy/curly quotes '.

This may take a few tries to get right since Windows doesn't deal well with fancy quotes on the command line, as you can see from the exiftool output.  First, you'll want to change the command lines code page as per FAQ #18 (https://exiftool.org/faq.html#Q18).

The try
exiftool -api "Filter=s/'//g" -TagsFromFile @ -Keywords -Subject /path/to/files/

Hopefully, that will work.  If not, try adding the -L (latin) option (https://exiftool.org/exiftool_pod.html#L--latin).

You may have to copy/paste the quote from Bridge as it may not be the exact quote mark I used here.  I believe there might be a couple variations.
Title: Re: How can I removed single quotation marks (ie 20's) from Keywords
Post by: Phil Harvey on March 26, 2022, 10:58:51 PM
... or you could remove all non-ascii characters like this:

exiftool api "Filter=s/[^ -~]//g" -TagsFromFile @ -Keywords -Subject /path/to/files/

- Phil
Title: Re: How can I removed single quotation marks (ie 20's) from Keywords
Post by: E_Rap on March 27, 2022, 09:16:47 AM
It worked perfectly!  Thank you!!