Skip to main content
Participant
November 21, 2017
Answered

Remove quotations around keywords

  • November 21, 2017
  • 1 reply
  • 2486 views

I used an api to add keywords to stock photos but all the keywords came over wrapped in quotes and display as one giant keyword. Is there a way to batch remove the quotations around the keywords in the keyword field?

Thanks

This topic has been closed for replies.
Correct answer SuperMerlin

Thanks, that image is indeed helpful.

The ExifTool command will correctly remove the quotes and split the single long keyword to individual keywords.

However the keywords are stored as an old/depreciated IPTC:Keyword category, rather than in the expected/current DC:Subject category.

Therefore a change in the command is required:

exiftool -r -sep ", " -tagsfromfile @ -keyword 'MacOSPATHtoFILEorFOLDER'

exiftool -r -sep ", " -tagsfromfile @ -keyword "WinOSPATHtoFILEorFOLDER"

These commands will create a new file, the original filename will be changed to include _original at the end of the name. An additional command can be included to -overwrite_original files (work on copies, create backups and test thoroughly before doing so).

You could also copy the legacy Keywords metadata into the Subject metadata, that way both old and new applications are covered:

exiftool -r -sep ", " -tagsfromfile @ -keywords '-subject+<${keywords}' FILEorFOLDER


A bit late but here is a Bridge script for the same

#target bridge  

   if( BridgeTalk.appName == "bridge" ) { 

sepkeys = MenuElement.create("command", "Seperate Keywords", "at the end of Tools");

}

sepkeys.onSelect  = function () {  

var thumbs = app.document.selections;

if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");

var FolderName =  decodeURI(Folder(app.document.presentationPath).name);

for(var a =0;a<thumbs.length;a++){

var selectedFile =  new Thumbnail(thumbs);   

app.synchronousMode = true;

var xmp = new XMPMeta(selectedFile.synchronousMetadata.serialize());

var keys = getArrayItems(XMPConst.NS_DC,"subject");

if(keys.length == 1){

xmp.deleteProperty(XMPConst.NS_DC,'subject');

keys = keys[0].toString().replace(/"/g,'').split(",");

for(var k in keys){

xmp.appendArrayItem(XMPConst.NS_DC, "subject", keys.toString(), 0,XMPConst.PROP_IS_ARRAY);

}

var newPacket = xmp.serialize(XMPConst.SERIALIZE_USE_COMPACT_FORMAT);

selectedFile.metadata = new Metadata(newPacket);

    }

}

ExternalObject.AdobeXMPScript.unload();

ExternalObject.AdobeXMPScript = undefined;

function getArrayItems(ns, prop){

var arrItem=[];

var items = xmp.countArrayItems(ns, prop);

for(var i = 1;i <= items;i++){

arrItem.push(xmp.getArrayItem(ns, prop, i));

}

return arrItem;

};

};

Stephen Marsh
Community Expert
Community Expert
November 22, 2017

There is not enough info to test and recommend a solution yet:

“keyword 1, keyword 2, etc”

“keyword 1,keyword 2,etc”

“keyword 1; keyword…”

“keyword 1;keyword…”

Or something else? Details matter…

Can you provide a sample file to download (even if cropped down, it is only the metadata that is critical)… Or even post a metadata panel > IPTC Core screenshot in the forum of the exact issue? Can you also show what the File > File Info window shows on the Advanced tab?

ExifTool can correct this, and with Bridge you could probably use one of many import/export from spreadsheet scripts to rework the data, there may even be a script for this if you are lucky.

Presuming that the separator is a comma ExifTool would use this command:

exiftool -r -sep ", " -tagsfromfile @ -subject 'MacOSPATHtoFILEorFOLDER'

And would change this:

<dc:subject>

            <rdf:Bag>

               <rdf:li>one, big, keyword</rdf:li>

            </rdf:Bag>

</dc:subject>

To this:

<dc:subject>

            <rdf:Bag>

               <rdf:li>one</rdf:li>

               <rdf:li>big</rdf:li>

               <rdf:li>keyword</rdf:li>

            </rdf:Bag>

</dc:subject>

Participant
November 22, 2017

The keywords are displayed like this: “keyword 1,keyword 2,etc”

Stephen Marsh
Community Expert
Community Expert
November 22, 2017

It is not the quotes that are the main issue, it is that multiple keywords are combined into a single keyword.

The ExifTool command posted earlier will fix that.

A sample file is more helpful...

Using file > file info do you see the quotes in the raw tab or advanced tab or any other tab, or only in the metadata panel?