exiftool via perl scripts

Started by nikkon, March 17, 2012, 06:38:05 PM

Previous topic - Next topic

nikkon

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




Phil Harvey

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 for all the details.

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