ExifTool Forum

ExifTool => Newbies => Topic started by: fabiano.santini on January 16, 2015, 08:27:40 AM

Title: Batch recursive process with output metadata filename equl to folder filname
Post by: fabiano.santini on January 16, 2015, 08:27:40 AM
This is my first post.
I hope had chosen the right place otherwise I am sorry.

I have many folders where there are many .tif files from scanner, the output that I need is a .csv file for each folder.

My approach is to create a .bat file with single exiftool line like:

/tt
exittool  -csv "list of all tags that I need" G:\mainfolder\folder_1 > c:\metadata\folder_1.csv

does exist any option in order to obtain the same result with only one command line using -r but telling to exiftool to generate for each folder  processed (many .tif files) a single .csv file with a file name equal to the folder name?

Thanks for your support

Fabiano Santini



Title: Re: Batch recursive process with output metadata filename equl to folder filname
Post by: Phil Harvey on January 16, 2015, 08:58:19 AM
Hi Fabiano,

This is very tricky.  The -w option almost gives you what you need, but it may not be combined with the -csv option, so you would have to use something like the -p option instead.  The sequence could look like this:

1. cd G:\mainfolder

2. exiftool -p "$TAG1,$TAG2,..." -r -w+! c:\metadata\%-.1d.csv .

This should work provided the tag values don't contain commas.  If there is a possibility of a comma in a tag, an advanced formatting expression may be used to translate, remove or escape them as necessary.

One trick here was that I needed to remove the trailing "/" from the directory name to use it as a file name.  (This is done using %-.1d instead of just %d in the -w argument.)

Another trick is that I needed to change to the source directory and specify "." as the source to start from this point with the %d.

Note that if there are any image files in the root source directory, this command will create a file named "..csv" for these.

- Phil
Title: Re: Batch recursive process with output metadata filename equl to folder filname
Post by: fabiano.santini on January 17, 2015, 10:05:08 AM
Thanks Phil, I tried your suggestion and it seems running well except for the TAG $Directory that is ./ followed by the foldername

Thanks again
Title: Re: Batch recursive process with output metadata filename equl to folder filname
Post by: Phil Harvey on January 17, 2015, 03:05:40 PM
You can massage the $directory tag into anything you want using the advanced formatting feature.  For example:

${directory;s(\.)(G:/mainfolder)}

to replace the "." with "G:/mainfolder".

- Phil