How to make -tagsfromfile assign tags based on file name corresponding entries

Started by painter, April 03, 2021, 05:34:53 PM

Previous topic - Next topic

painter

I have a dates.xml file containing ExifIFD:CreateDate tag information for multiple files:


...
<rdf:Description rdf:about='IMG_0226.jpg'
  xmlns:et='http://ns.exiftool.ca/1.0/' et:toolkit='Image::ExifTool 12.22'
  xmlns:ExifIFD='http://ns.exiftool.ca/EXIF/ExifIFD/1.0/'>
<ExifIFD:CreateDate>2002:09:12 00:00:00+02:00</ExifIFD:CreateDate>
</rdf:Description>

<rdf:Description rdf:about='IMG_0227.JPG'
  xmlns:et='http://ns.exiftool.ca/1.0/' et:toolkit='Image::ExifTool 12.22'
  xmlns:ExifIFD='http://ns.exiftool.ca/EXIF/ExifIFD/1.0/'>
<ExifIFD:CreateDate>2002:09:12 00:01:00+02:00</ExifIFD:CreateDate>
</rdf:Description>
...


My hope was, -tagsfromfile would consider the rdf:about attribute for the assignment, but it does not. At least


exiftool.exe -tagsfromfile dates.xml  *.jpg


just takes the first ExifIFD:CreateDate tag entry from the .xml and adds it to all files. How can I make it add the correspoding entry from the file to each .jpg?

Phil Harvey

Unfortunately the -X (XML) output may not currently be used to input a database for multiple files.  For this, you must use -json or -csv.

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

painter

Many thanks for the quick reply.

But no luck with -json.

I tried to import from


[{
  "SourceFile": "IMG_0226.jpg",
  "ExifIFD:CreateDate": "2002:09:12 00:00:00+02:00"
},
{
  "SourceFile": "IMG_0227.jpg",
  "ExifIFD:CreateDate": "2002:09:12 00:01:00+02:00"
},
...


with

exiftool.exe -tagsfromfile exifall.json  *.jpg

but now I get the Warning: No writable tags set from exifall.json. I tried omitting/changing the group name, tags that definitely exist in the files, -addtagsfromfile, ..., but got allways the same. 

The json file was created using

exiftool.exe -json -file:filemodifydate *.jpg > exifall.json

and then I modified the tag entries.

Any hint?




StarGeek

You need to use the -j (-json) option to rewrite the data.
exiftool.exe -j=exifall.json -ext jpg .

Also, see Common Mistake #2 for the pitfalls of using wildcard filenames.  It's better to use a dot to indicate the current directory and the -ext (-extension) option to limit the scope.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

painter

Thanks, StarGeek. Right, actually I had to use

exiftool.exe -json="exifall.json" -ext jpg .

This finally worked.

One note: Before this worked, however, an encoding problem popped up:

The json file was created using

exiftool.exe -json -file:filemodifydate *.jpg > exifall.json

With this file used as input file, exiftool complained about a Format error in JSON file 'JSON file'. In Notepad++ the encoding was named UCS-2 LE-BOM. Only after changing the encoding to UTF-8 or ANSI, the file was accepted by exiftool. ExifToolVersion is 12.22.