ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: mjb on July 04, 2021, 09:04:22 AM

Title: Use value from batch file within config file
Post by: mjb on July 04, 2021, 09:04:22 AM
Hello

I'm using a batch file to run ExifTool with a custom config file:


...
REM assign date time string: yyyymmdd_hhnnss
set DT=%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%
set DT=%DT: =0%
...
ExifTool -config ExifTool_ImageMagickThumbMWG_THUMBS.config -G1 -a -s -IMCommandMWG -api requestall -@ ExifTool_ImageMagickThumbMWG_ARGS.args -T ImageFolder -r -w ImageFolder_BATCH_!DT!/%%f_%%.9nC.bat -b
...


Here the destination folder has a datetime suffix given by '_!DT!'.

Is it possible to somehow send !DT! as an argument to the config file?

I know I can get datetime value (from 'Now') within the config file but I need it to be a fixed value and not updated for each file that is processed.

Regards
Michael
Title: Re: Use value from batch file within config file
Post by: StarGeek on July 04, 2021, 11:35:23 AM
You can pass a value to the config file by using the -userParam option (https://exiftool.org/exiftool_pod.html#userParam-PARAM-VAL).  See the UserParam API entry (https://exiftool.org/exiftool_pod.html#userParam-PARAM-VAL).
Title: Re: Use value from batch file within config file
Post by: mjb on July 04, 2021, 01:05:14 PM
That's great, thanks very much. Have now achieved what I was after. Got it working using your forum post GPS2MapUrl user defined tags as an example.

Here's what's working for me:

command batch file:

...
REM assign date time string: yyyymmdd_hhnnss
set DT=%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%
set DT=%DT: =0%
...
ExifTool -config ExifTool_ImageMagickThumbMWG_THUMBS.config -G1 -a -s -IMCommandMWG -userparam dt=!DT! -api requestall -@ ExifTool_ImageMagickThumbMWG_ARGS.args -T ImageFolder -r -w ImageFolder_BATCH_!DT!/%%f_%%.9nC.bat -b
...


ExifTool_ImageMagickThumbMWG_THUMBS.config:

...
#------------------------------------------------------------------------------
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
...
        IMCommandMWG => {
...
            ValueConv => q {
...
                my $datetime = $self->Options('UserParam')->{'dt'};
                print "$datetime\n";

            },
        },
    },
);
#------------------------------------------------------------------------------
1;  #end



Thanks also to user grimmo and yourself for the post Extract an jpg image corresponding to the face detected area from digikam.

Regards
Michael




GPS2MapUrl user defined tagshttps://exiftool.org/forum/index.php?topic=9862.0 (https://exiftool.org/forum/index.php?topic=9862.0)
Extract an jpg image corresponding to the face detected area from digikamhttps://exiftool.org/forum/index.php?topic=10879.0 (https://exiftool.org/forum/index.php?topic=10879.0)

Title: Re: Use value from batch file within config file
Post by: StarGeek on July 04, 2021, 05:29:59 PM
Glad you figured it out.

I didn't think anyone would be using that imagemagick config.  It is on my list to enhance it, to call Magick directly and either save the thumbs, or have the thumbnails passed directly back to exiftool and they could be saved using the -W (-TagOut) option (https://exiftool.org/exiftool_pod.html#W-FMT--tagOut), similar to the example command (https://exiftool.org/exiftool_pod.html#exiftool--a--b--W-d-f_-t--c.-s--preview:all-dir) that saves out the preview images.

Title: Re: Use value from batch file within config file
Post by: mjb on July 05, 2021, 06:36:35 AM
That would be great and many thanks for your help.

For now, I've managed to cobble together some code (from yourself and others) which does 2 things:
Reason for all this is to identify image face regions after using "Write Faces to XMP" in Picasa.

In case this is of interest to anyone I have attached relevant files:





ExifTool_ImageMagickThumbMWG_ARGS.args
ExifTool_ImageMagickThumbMWG_COMMAND.bat
ExifTool_ImageMagickThumbMWG_PEOPLE.config
ExifTool_ImageMagickThumbMWG_THUMBS.config

REQUIREMENT
ExifTool
ImageMagick (either installed or system environment variable 'Path' pointing to portable version folder)
Windows

SETUP
ExifTool.exe should be placed next to (ie at same level) as source folder/directory of files to be processed.
Attached files should be placed at same level as source folder.
Edit 'ExifTool_ImageMagickThumbMWG_COMMAND.bat' to change name of source folder (search for 'set SOURCE_FOLDER=').

RUN
Double-click on 'ExifTool_ImageMagickThumbMWG_COMMAND.bat'.

OUTPUT
New files and folders are created at same level as source folder:




sourcefolder_PEOPLE_datetime.csv..........summary csv file listing
sourcefolder_BATCH_datetime..........folder of batch files for all images found with face regions
sourcefolder_THUMBS_datetime..........folder hierarchy of extracted face thumbnail images

NOTES
Advise back up of original image files.
Advise experimenting on test hierarchy of images.
My code probably not very pretty but all works OK on my system.

DISCLAIMER
Use at own risk.
Title: Re: Use value from batch file within config file
Post by: mjb on July 06, 2021, 08:46:43 AM
updated files attatched...

ExifTool_ImageMagickThumbMWG_THUMBS.config renamed to ExifTool_ImageMagickThumbMWG_THUMB.config
ExifTool_ImageMagickThumbMWG_COMMAND.bat edited