Checking if xml exists and using another -srcfile if none exists.

Started by sjDelaney, May 07, 2016, 05:58:31 PM

Previous topic - Next topic

sjDelaney

Quote from: Phil Harvey on June 17, 2012, 08:58:14 PM
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



This comes from an old thread, but it concludes with confirming that multiple -srcfile (s) can be used for read and write.

...-srcfile finename.xmp -srcfile filename.nef...

The example you give is for command line; what would that look like using the API?

sjDelaney


sjDelaney

Actually I thought I had this resolved but I'm not quite there.  I'm sure I have the Perl logic current (it tests out), but the output (xmp) files are huge and seem to be actually jpegs with xml extensions.  They are huge (Up to 14MB), Preview in Finder as images, and are unreadable with a text editor.

Here is the WriteInfo syntax I'm using...

$Write = $exifTool->WriteInfo($File,$XMPFile);    #Where $File is a jpg but could potentially be a raw file.

I tried to update a relatively small output file (2MB) as an attachment, but the post would not accept it.

Phil Harvey

Right.  WriteInfo() only writes metadata to the specified file.  It does not change file types.  The exiftool application calls SetNewValuesFromFile() then WriteInfo() with an undef source file to create an XMP file from scratch.

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