ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: empedia on November 07, 2012, 11:12:01 AM

Title: Using backslash with -sep operator
Post by: empedia on November 07, 2012, 11:12:01 AM
Hi,

I am using exiftool to extract metadata from DICOM files.

The tags I am specifically interested in are

ImagePositionPatient and ImageOrientationPatient which are tags used by Philips Dicom format

When I run the cmd line version of exiftool on Windows I get the following sort of output

Image Position Patient          : -29.635969161987\42.2112464904785\12.0020151138305
Image Orientation Patient       : 0.42902336858444\0.89619832565966\0.11299340818506\0.26550329955296\-0.0055465998779\-0.9640939960171

The values are delimited by backslashes and I would like to be able to use the -sep operator to separate the string into a list - and ideally also to use the -p operator to output each item in the list separately. Ultimately to generate an xml snippet something like this

<ImagePositionPatient>
<value>-29.64</value>
<value>42.41</value>
<value>12.00</value>
</ImagePositionPatient>

I've shortened the values for brevity

However when I use - sep "\" exiftool just gives me the help text - I also tried "\\" which did not recognise the tag separator.

So is what I am trying to do possible and if so how?

Many thanks,

Matthew Dexter
Title: Re: Using backslash with -sep operator
Post by: Phil Harvey on November 07, 2012, 11:31:53 AM
Hi Matthew,

Unfortunately all DICOM tags like this are stored as simple strings, not as lists of items, which is why the -sep option has no effect.

I can't suggest anything I can do to make your job simpler.  At some point you'll have to process the string yourself to achieve the result you are looking for.  If it helps, you can use an ExifTool user-defined Composite tag (https://exiftool.org/config.html) to do some of the reformatting.

- Phil