Adding dates to your photos.

2009-10-12 134 words 1 min read

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">


Tags: Linux Photo

author

Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it