What is the proper syntax for writing to separate files?

Started by kbellis, January 29, 2014, 07:58:50 PM

Previous topic - Next topic

kbellis

In this example:
echo "BaseName<tab>Date<tab>Time_into_x<tab>LightValue_into_y" > %1\test.cor
C:\ExifTool\exiftool -config C:\ExifTool\.test_config -T -r -n -basename -Time_into_x -LightValue_into_y %1 >> %1\test.cor


the result is a single report (test.cor) which contains the requested and recursive data into a single collective file. But what if you want to write that requested and recursive data into individual discrete files prefixed with the file name; e.g.:

BaseName0001_test.cor
BaseName0002_test.cor
BaseName0003_test.cor
etc.,


What is the proper syntax in the call(s) from the .bat file?

Thank you for any reply.

Kelly

Phil Harvey

Hi Kelly,

Is there one output text file per image (ie. do you want to store the output files in a flat directory, and are there duplicate source files with the same name)?

Do you want the header row to be written to each output 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 ($).

kbellis

Hi Phil,

Thanks for the reply.

Actually, the echo / header call isn't necessary for each output file; and yes, one output file per image.

The source file; e.g., 4567.cr2 and the output file, again for example, 4567_test.cor would be in the same directory.

Kelly

Phil Harvey

Hi Kelly,

OK then, this is easy:

exiftool -config C:\ExifTool\.test_config -T -r -n -basename -Time_into_x -LightValue_into_y -w %d%f_test.cor %1

(if you didn't want the "_test" added, it would have been simpler: "-w cor")

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

kbellis

Wow - powerful and so elegant in simplicity.

Thanks Phil!

Kelly

Phil Harvey

Hi again,

Ooops.  I just realized you are using this in a .BAT file, so the "%" characters need to be doubled:

exiftool -config C:\ExifTool\.test_config -T -r -n -basename -Time_into_x -LightValue_into_y -w %%d%%f_test.cor %1

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

kbellis

I actually used the simpler:
C:\ExifTool\exiftool -config C:\ExifTool\.test_config -T -r -n -basename -Time_into_x -LightValue_into_y -w cor %1
and the bat ran without issue (except I forgot about some sub-directories that I had later added and the recursive part worked there too ;) )

Noting: I didn't double up the percentage character and it worked fantastically - as advertised :)

Phil Harvey

Right.  My last post doesn't apply if you use the simple "-w cor".

Glad it worked.

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