Adding dates to your photos.

2009-10-12 1 min read Linux Photo
Add date in the photograph with a perl script.

#!/usr/bin/perl

if ($#ARGV < 0 )
{
print &#8221;$#ARGV \n&#8221;;
print &#8221;Usage $ARGV[0] filename/dir\n&#8221;;
exit -1;
}

@files = `find &#8221;$ARGV[0]&#8221; -iname &#8221;*jpg&#8221; -print`;

if ($#ARGV > 3 ) { $cmd = 1;}
$count = 1;
foreach $file (@files) {
chomp ($file);

@details = `exif1 &#8217;$file&#8217;`;

$flag = 1;
$flag2 = 0;
$flag_w = 0;
$date = &#8221;&#8221;;
foreach $det (@details) {
@words = split(/–>/, $det);
$_ = $det ;
chomp($words[1]);
if (/Date/ ) {
$date =$words[1] ;
$flag = 0;
}
}

if ($flag) {
@details = `exiftool &#8217;$file&#8217;`;
foreach $det (@details) {
@words = split(/ : /, $det);
$_ = $det ;
chomp($words[1]);
if (/Date\/Time Original/ ) {
$date =$words[1] ;

}
}
}
system(&#8221;annotate &#8221;$date&#8221; &#8221;$file&#8221; &#8221;$file&#8221;&#8221;);

$count ++;
} <a name="more">

comments powered by Disqus