Using -w with -o: where should my output file go?

Started by busywait, December 10, 2017, 10:25:52 AM

Previous topic - Next topic

busywait

I am using exiftool 10.60, testing in a Windows powershell prompt.

I have an exiftool command line that uses -w to specify a file to use for output of an embedded preview image, like this:
/path/to/exiftool -b -PreviewImage -w "output sub dir/%f_%ue.jpg" -execute -tagsfromfile %f.%e -srcfile "output sub dir/%f_%ue.jpg" -overwrite_original -common_args file.raw

PS C:\EXIF> .\exiftool.exe -b -PreviewImage -w "output sub dir/%f_%ue.jpg" -execute -t
agsfromfile %f.%e -srcfile "output sub dir/%f_%ue.jpg" -overwrite_original -common_args  file.orf
    1 directories created
    1 output files created
    1 image files updated


I thought that I would be able to add the option -out "output sub dir/" in common args to specify the location of the output, file_RAW.jpg, but that is not what happens - in fact with -out "output sub dir/" the file test.raw is simply copied to "output sub dir/", and my preview image is not extracted.

PS C:\EXIF> .\exiftool.exe -b -PreviewImage -w "%f_%ue.jpg" -execute -tagsfromfile %f.
%e -srcfile "output sub dir/%f_%ue.jpg" -overwrite_original -common_args -out "output sub dir/" file.orf
    1 directories created
    1 image files copied
    0 output files created
Error: Error opening file - output sub dir/file_ORF.jpg
    0 image files updated
    1 files weren't updated due to errors


Have I misunderstood?

The example is simplified, I actually have a config file with several -w options, and it would be nice to be able to specify or change the output folder just once at the top of my exiftool args file.

(As a feature request, to reduce duplication in my command line or config file it would be nice to reference the -out value in any file format string, perhaps using %o to mean "the value set by -out".)


Phil Harvey

I agree that this is a bit confusing, but -o is to specify the output image file when writing.  -w specifies the output text file when reading.

It is confusing because the output image file may in fact be a metadata-only file, and the output text may in fact be a binary image.

The diagram in this overview may help make things more clear.

I don't understand exactly how you would want to use your %o suggestion, but logically it would be difficult because the output file name is determined as the last step in the processing, and it would require some restructuring to make it available earlier.

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

busywait

Thank you - yes the whole page is helpful - my particular usage here stretches the labels used in the diagram I think :)

In the diagram, the -w option (that I am using to write a .jpg binary file) leads to the box labelled "Output text files". The -o leads to a box labelled "Output metadata files".

With my current understanding, I interpret the boxes in this way
[Output text files] == [Output selected tag values to file, formatted in text, or binary as requestd]
[Output image files] and [Output metadata files] == [Output image or image sidecar files]

An example of the simplification that I'd like is to be able to specify an output directory option that applies to anything written, eg to -o and -w options, on the right-hand side of your "Overview of Exiftool" diagram. Because I have a chain of -execute statements, I want to be able to reference that subfolder in the -srcfile parameter too.

So, to create a new subdir to write extracted tag values in to, in multiple passes, I'd perhaps use a command like this:

.\exiftool.exe -b -PreviewImage -w "%f_%ue.jpg" -execute -tagsfromfile %d%f.%e -srcfile "%O%f_%ue.jpg" -overwrite_original -common_args -O "Output Sub Dir/" file.orf

The combination of -O and %O could turn three hard-coded uses of "Output Sub Dir/" into one in this simplified example, and would be even more helpful in my real world use.

However, you already told me that is not how exiftool is structured, so I'm just giving this example as an exercise in wishful thinking :)



Phil Harvey

I see.  Thanks for the example. 

It sounds like your current understanding is good.

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