Check for sidecar files

Started by MOL, June 16, 2012, 11:48:18 AM

Previous topic - Next topic

MOL

Hi Phil,

just a quick question: is there a switch I could use to check whether there is a sidecar available for a file, and if yes, use that sidecar to read/write metadata instead of the main file?

TIA
Uwe

Phil Harvey

Hi Uwe,

ExifTool doesn't deal with sidecar files, and leaves this up to the user.

But let met think about this.  Maybe this is a feature that I can add.

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

MOL

Hi Phil,

that would be great, thank you.

-Uwe

Alan Clifford

Quote from: Phil Harvey on June 17, 2012, 10:11:51 AM
Hi Uwe,

ExifTool doesn't deal with sidecar files, and leaves this up to the user.

But let met think about this.  Maybe this is a feature that I can add.

- Phil

Phil I think this would be a really good idea.  In my program using the exiftool libraries, I automatically use the sidecar file for, for instance, setting/reading the xmp:datetimeoriginal, gps and other stuff for movies that can't be updated.

It would be a useful extension, I think, to update/read a sidecar file by exiftool in similar circumstances.

Maybe good for raw files too, that have had sidecar files written by other software.


Alan

MOL

Hi again

I would like to see something along these lines, if possible:

- use a switch to turn the feature on
- if the 'Read/write from sidecar' feature is enabled, ExifTool checks if there is a sidecar available for the selected file
- if yes, bypass the image file completely and read/write metadata directly from/to the sidecar
- if the feature is disabled, read/write from/to the original image file, bypassing the sidecar even if there is one available

-Uwe

lks

What a coincidence this thread just appeared, as I was just about to ask for a similar feature before doing a forum search!

Basically I would like the following behavior:

- have a mode to either switch on sidecar support or not
- if sidecar support is off, program behaves like it currently does
- if sidecar support is on, read metadata from original file if sidecar doesn't exist, otherwise read it from the sidecar.  Writing of metadata would always to to the sidecar.
- sidecar naming rules could be similar to -srcfile option

Thanks for considering this.

Phil Harvey

I am thinking about implementing this without adding any new options.  I think I can do what you want by allowing multiple -srcfile options to specify more than one source.  If the first specified source file doesn't exist, then exiftool would move on to the next, etc.  If none exists, exiftool would attempt to write the first one in list anyway (ie. to create a .XMP file).  The command would be something like this:

exiftool -srcfile %d%f.xmp -srcfile @ -artist=me -ext nef DIR

This command would write to a sidecar XMP if it exists, otherwise to the original raw file for all NEF images in directory DIR.

Provided there are not hitches in implementation, this could appear in ExifTool 8.96

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

lks

I appreciate any changes you make along these lines.  That having been said...

Would it be possible to always write to the first -srcfile argument, regardless of whether that file existed or not?  (To be clear, I like the way you have specified the reading behavior would work.)

Then I could make the sidecar the first argument, the original raw file the second argument, and the raw file would effectively be "read-only."

Alan Clifford

Quote from: lks on June 18, 2012, 01:21:32 AM
Then I could make the sidecar the first argument, the original raw file the second argument, and the raw file would effectively be "read-only."

I like that writing logic.

As for reading, consider a scenario:  You don't want to touch your original .nef files but the datetimeoriginal is incorrect.  So you touch the .xmp file to create it and then add 5 hours to datetimeoriginal value.  I'm assuming that the proposition is to take the first exif:datetimeoriginal in the .nef and create the xmp:datetimeoriginal in the .xmp.  Then you decide you want to add 5 seconds to make the time perfect.  Would repeating the command add 5 seconds to the value of the exif:datetimeoriginal in the nef and overwrite the xmp:datetimeoriginal in the .xmp, which would lose the 5 hour change? (I'm assuming you haven't specified the flavour of datetimeoriginal you are using in the second command).  Or would the xmp:datetimeoriginal in the .xmp be considered the first datetimeoriginal?


Alan


Phil Harvey

Quote from: lks on June 18, 2012, 01:21:32 AM
Would it be possible to always write to the first -srcfile argument, regardless of whether that file existed or not?  (To be clear, I like the way you have specified the reading behavior would work.)

Then I could make the sidecar the first argument, the original raw file the second argument, and the raw file would effectively be "read-only."

This functionality already exists with the -srcfile option.

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

Phil Harvey

Quote from: Alan Clifford on June 18, 2012, 07:07:49 AM
You don't want to touch your original .nef files but the datetimeoriginal is incorrect.  So you touch the .xmp file to create it and then add 5 hours to datetimeoriginal value.  I'm assuming that the proposition is to take the first exif:datetimeoriginal in the .nef and create the xmp:datetimeoriginal in the .xmp.  Then you decide you want to add 5 seconds to make the time perfect. 

1. exiftool -o %d%f.xmp -ext nef DIR

2. exiftool -datetimeoriginal+=5 -srcfile %d%f.xmp -ext nef DIR

The first command creates an XMP sidecar file for all NEF images in directory DIR that don't already have one.

The second command adds 5 hours to DateTimeOriginal in the sidecar files.

See the Metadata Sidecar Fies documentation for more details.

This functionality doesn't require the new feature that Uwe had requested:  To be able to write the sidecar file only if it exists, otherwise write the original file.

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

Alan Clifford

Quote from: Phil Harvey on June 18, 2012, 07:35:15 AM

The first command creates an XMP sidecar file for all NEF images in directory DIR that don't already have one.

The second command adds 5 hours to DateTimeOriginal in the sidecar files.
...


Thanks Phil, I didn't realize that.  I need to read more.

Alan

lks

Quote from: Phil Harvey on June 18, 2012, 07:28:46 AM
Quote from: lks on June 18, 2012, 01:21:32 AM
Would it be possible to always write to the first -srcfile argument, regardless of whether that file existed or not?  (To be clear, I like the way you have specified the reading behavior would work.)

Then I could make the sidecar the first argument, the original raw file the second argument, and the raw file would effectively be "read-only."

This functionality already exists with the -srcfile option.

- Phil

Sorry, Phil, I am not sure I understand.  Are you saying both the read behavior (keep trying -srcfile options until you find one that exists, or the original srcfile itself otherwise) and the write behavior (always write to the first srcfile option) are in the current version of exiftool?

Phil Harvey

Quote from: lks on June 18, 2012, 10:37:13 AM
Sorry, Phil, I am not sure I understand.  Are you saying both the read behavior (keep trying -srcfile options until you find one that exists, or the original srcfile itself otherwise) and the write behavior (always write to the first srcfile option) are in the current version of exiftool?

Ah, OK.  I was talking about the write behaviour which exists already.

The read behaviour to read from a sidecar it it exists or otherwise the original is Uwe's request.

So you will be able to do both, but of course you will need different command lines for reading and writing.

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

lks

That would be perfect!  Then I'll just need exiftoolgui to cooperate...