I'm using exiftool to pull specified tags out of a large number of image files and import them into a sqlite DB. When using the -f flag, it appears that the SourceFile tag is output twice. Here's a simplified example of the behavior:
CSV output with -SourceFile tag works as expected - the tag is output once:
./exiftool -ver -csv -SourceFile IMG_1075.JPG
11.48
SourceFile
IMG_1075.JPG
If you add the -f flag the column is repeated. This causes sqlite import of the resulting csv file to fail due to the duplicate column name. Also notice that the second value is incorrect:
./exiftool -ver -f -csv -SourceFile IMG_1075.JPG
11.48
SourceFile,SourceFile
IMG_1075.JPG,-
The workaround is to not specify the -SourceFile tag as it appears to be output by default even when listing other tags, but this is kind of unexpected behavior:
./exiftool -ver -f -csv -FileSize IMG_1075.JPG
11.48
SourceFile,FileSize
IMG_1075.JPG,4.2 MB
There is no tag named SourceFile. It only exists in the CSV output (see -csv option (https://exiftool.org/exiftool_pod.html#csv-CSVFILE), first paragraph).
If you run
exiftool -SourceFile IMG_1075.JPG
you will get no output, as there isn't anything to list. The addition of the -f (ForcePrint) option (https://exiftool.org/exiftool_pod.html#f--forcePrint) forces exiftool to create output for this non-existent tag. That's why you get a second column.
Thanks