Changing keyword hierarchical separator

Started by Hugh, November 22, 2016, 11:14:26 AM

Previous topic - Next topic

Hugh

I have photos with keyword metadata created by WLPG in the typical form:
XPKeywords                      : Places/France/Champagne/Other Champagne;Places of Interest/Vineyards

I would like to change the separator from / to |

Following the example at https://exiftool.org/forum/index.php?topic=6516.0 I have tried a Windows batch file readingcd C:
cd "\ExifTool\Before"
"C:\ExifTool\exiftool.exe" -k -r -sep "; " "-XPKeywords<${XPKeywords;s/\///\|g}" * -o "C:/ExifTool/After/%%d/"
but the output still has / as separator.


Phil Harvey

Close, but you have a couple of problems.  Try this:

exiftool -k -r "-xpkeywords<${xpkeywords;tr(/)(|)}" -o "C:/ExifTool/After/%%d/" .

The problem that was stopping you was a syntax error in your substitution expression.  I have changed this to "tr" and used brackets to make it more readable.

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

Hugh

Thanks. That works.

(What was wrong with the s syntax? Was it following /\// by /\| ? Would it be possible with s instead of tr?)

Phil Harvey

s/\//\|/g <-- this should work
s/\///\|g <-- you had this
...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 ($).