How can I removed single quotation marks (ie 20's) from Keywords

Started by E_Rap, March 22, 2022, 02:27:37 PM

Previous topic - Next topic

E_Rap

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}"

StarGeek

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.
     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 to use regex to remove single quotes.  It affects each keywords separately.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

E_Rap

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/

Phil Harvey

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
...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 ($).

StarGeek

Run this command and copy/paste the output here
exiftool -G1 -a -s -Subject -Keywords file.jpg
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

E_Rap

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)

StarGeek

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.

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.

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.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

... or you could remove all non-ascii characters like this:

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

- 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 ($).