#!/usr/bin/perl -w # # ADDING DATES TO SCANNED PHOTOS OR NEGATIVES # # Kim Briggs 2009-12 http://kimbriggs.com/computers/ # # Script uses the exiv2 program http://www.exiv2.org/ # to add EXIF date and metadata to JPGS (and rename with new timestamp). # # Process ONE ROLL of film at a time (59 pics max). # Numbering sequence is from NOON, i.e., 120100 to 125900. # # Reference of EXIF format: Date Taken: 2009:10:07 15:24:02 # ModifyDate=DateTime(EXIFspec) # CreateDate=DateTimeDigitized(EXIFspec) # DateTimeOriginal(ExifIFD) # exiv2 -pt = print all the exif tags to screen # # NOTE: The "date photo taken" has failed to show up under Windows XP # when the date is prior to 1980. I have no idea why. # print "Enter Your Name: "; chomp($my_name = <>); print "Enter the Year(YYYY): "; chomp($my_year = <>); print "Enter the Month(MM): "; chomp($my_month = <>); print "Enter the Day(DD): "; chomp($my_day = <>); # Load all jpgs into an array. Use the same suffix for all files to preserve your order. # There will be an error message about the suffix you didn't use. Ignore it. @pix = `ls *.JPG *.jpg`; $my_count = 0; foreach $pix (@pix) { if ($my_count < 10) {$my_count="0$my_count";} print "Processing photo: ".$pix; # Use the program exiv2 to process EXIF metadata and rename the file with timestamp system("exiv2 -M'set Exif.Image.Artist $my_name $my_website' $pix"); system("exiv2 -M'set Exif.Image.Copyright Copyright $my_year $my_name. All Rights Reserved.' $pix"); system("exiv2 -M'set Exif.Image.DateTime $my_year:$my_month:$my_day 12:$my_count:00' $pix"); system("exiv2 -M'set Exif.Photo.DateTimeOriginal $my_year:$my_month:$my_day 12:$my_count:00' $pix"); system("exiv2 -M'set Exif.Photo.DateTimeDigitized $my_year:$my_month:$my_day 12:$my_count:00' $pix"); # Comment out the line below with a "#" symbol to AVOID RENAMING the file system("exiv2 -r %Y_%m%d_%H%M%S $pix"); $my_count = int($my_count) + 1; }