Prepend slash to SourceFile?

Started by mdlr, April 19, 2018, 10:31:51 PM

Previous topic - Next topic

mdlr

I am using the follwing command to extract image data to a CSV:

exiftool -csv -r -filename -imagewidth -imageheight assets/photo/ > _data/images.csv


Which results in:

SourceFile,FileName,ImageWidth,ImageHeight
assets/photo/A.jpg,A.jpg,632,790
assets/photo/B.jpg,B.jpg,1280,800

In order to import this data, I need to prepend a slash to the SourceFile field; e.g. "/assets/photo/A.jpg"

Is there a way to do this?

Phil Harvey

One way to do this is to generate the CSV yourself using the -p option:

exiftool -echo "SourceFile,FileName,ImageWidth,ImageHeight" -p "/$directory/$filename,$filename,$imagewidth,$imageheight" assets/photo > _data/images.csv

This should work as long as no filename contains a comma or a quote.

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

mdlr

Quote from: Phil Harvey on April 20, 2018, 07:17:01 AM
One way to do this is to generate the CSV yourself using the -p option:

exiftool -echo "SourceFile,FileName,ImageWidth,ImageHeight" -p "/$directory/$filename,$filename,$imagewidth,$imageheight" assets/photo > _data/images.csv

This should work as long as no filename contains a comma or a quote.

- Phil

Works like a charm. Thanks, Phil.