ExifTool Forum

ExifTool => The Image::ExifTool API => Topic started by: nikkon on March 17, 2012, 06:38:05 PM

Title: exiftool via perl scripts
Post by: nikkon on March 17, 2012, 06:38:05 PM
I have reasonably mastered the exiftool on linux with the comand line via bash for my purposes

but 
what would be the pure perl equivalent of
exiftool -config exifh.cfg -Year='2012'  -Month='March'  -Day='12'   -FirstName= 'abcdef'  -Gender='rrrrrrrrr'    -Sport=' '   -overwrite_original    *.JPG
which works quite well via the comand line 
ie i have created a customised  config file  and trying to run it via a perl script -

alternatively if i want to get values out
exiftool -config exifh.cfg  -Year    -Month    -Day   -FirstName   -Gender   -Nationality      -Event   *.JPG
would give me the answers

additionally i am trying to build a customised "something"
for exiftool  via gtk2 in a tree-view collum 
basically cutting and pasting  and modifying from "net examples"
but when i try to put the exif output into the culoms  get long list of HASH(??????) NUMBERS


HAVING FUN BUT SOME ADVICE WOULD BE WELCOME

Thanks



Title: Re: exiftool via perl scripts
Post by: Phil Harvey on March 17, 2012, 08:04:00 PM
I'm not sure exactly what you are asking, but here is a perl script that will write the values in your first example using your config file:

#!/usr/bin/perl -w
use strict;
BEGIN { $Image::ExifTool::configFile = 'exifh.cfg' }
use Image::ExifTool;

my $et = new Image::ExifTool;

$et->SetNewValue(Year => '2012');
$et->SetNewValue(Month => 'March');
$et->SetNewValue(Day => '12');
$et->SetNewValue(FirstName => 'abcdef');
$et->SetNewValue(Gender => 'rrrrrr');
$et->SetNewValue(Sport => ' ');

opendir(DIR, ".");
for (;;) {
    my $file = readdir DIR;
    last unless defined $file;
    next if $file =~ /^\./ or $file !~ /\.jpg$/i;
    $et->WriteInfo($file);
}
closedir DIR;
# end


See the API documentation (https://exiftool.org/ExifTool.html) for all the details.

- Phil