ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Misty on August 31, 2012, 01:25:37 PM

Title: Writing XMP to stdout
Post by: Misty on August 31, 2012, 01:25:37 PM
This is hopefully just an EPEBKAC on my part, but I'm having difficulty writing XMP metadata to standard out.  I've tried a variety of commands, which typically produce the error "Error: Can't create file (unknown type) -" - leading me to think maybe Exiftool is relying on the format of the output file to determine how to write the output, which of course fails for stdout. The command I thought should work is:


exiftool -tagsfromfile input.MTS -all=xmp -o -


Which produces the message:


Warning: Can't set value for all tags
Error: Can't create file (unknown type) -


Replacing - with a filenname writes valid XMP as expected.
Title: Re: Writing XMP to stdout
Post by: Phil Harvey on August 31, 2012, 01:44:23 PM
Yes.  From the command line the only way that exiftool knows the output format is from the file extension.

Via the API, this may be specified, but the application currently doesn't have an option for this.

- Phil
Title: Re: Writing XMP to stdout
Post by: Misty on September 04, 2012, 11:27:07 AM
Thanks, Phil.

I'm not calling this from perl, so I'll just use a temporary file. Any chance of adding an option to specify the output format on the commandline so that writing to stdout could work?
Title: Re: Writing XMP to stdout
Post by: Phil Harvey on September 04, 2012, 12:54:24 PM
Thanks for the suggestion.  I'll keep this in mind, but I really try to resist adding new options -- there are too many already.  But you may get your wish if other people request this too.

- Phil
Title: Re: Writing XMP to stdout
Post by: Bilge on September 04, 2012, 03:28:41 PM
It should definitely be added. It is inappropriate to assume that everyone wants to output to files and therefore rely on inferencing type from file name.
Title: Re: Writing XMP to stdout
Post by: Phil Harvey on September 05, 2012, 08:42:13 AM
I'm thinking that maybe I can add this feature without creating a new option.  What about if I extend the -o option to allow a syntax like this:

exiftool -o -.EXT ...

which would write to stdout with a file format specified by EXT.

This breaks backward compatibility a little bit because now you'd have to do something like "-o ./-.xmp" instead of just "-o -.xmp" if you really wanted to create a file named "-.xmp", but I doubt anybody would ever want to do this anyway.

- Phil
Title: Re: Writing XMP to stdout
Post by: Phil Harvey on September 06, 2012, 09:47:51 AM
This new feature is now available with ExifTool 9.02.  Use "-o -.xmp" to write XMP output to the console.

- Phil
Title: Re: Writing XMP to stdout
Post by: Misty on September 06, 2012, 12:19:28 PM
Excellent, thank you Phil! It works great! Much appreciated.