This is a short post about how to duplicate or copy the EXIF information from one file to another using exiftool.
The command comes handy when you have one image with EXIF information and you would like another image to have the exact EXIF information.
exiftool -TagsFromFile CopyFromFile.NEF ToFile.JPG
This works in both Windows and Linux.
Posted by Hans-Henry Jakobsen
Sometimes a image files creation date is wrong and have to be corrected. This is a script I use to set a files creation date to the photos date retrieved from EXIF tags. The exiftool program should be available to run this script.
#!/usr/bin/env perl
use strict;
$|++;
use Image::ExifTool qw(ImageInfo);
use Time::Local;
for my $file (@ARGV) {
my $ii = ImageInfo($file, qw(DateTimeOriginal DateTime))
or warn("Skipping $file\n"), next;
my ($created) =
grep /\S/, @$ii{qw(DateTimeOriginal DateTime)};
next unless $created;
warn "using $created for $file\n";
if ($created =~ s/([-+ ])(\d\d):(\d\d)$//) {
my ($sign, $hour, $minute) = ($1, $2, $3);
# warn "ignoring offset of $sign $hour:$minute\n";
}
my @digits = $created =~ /(\d+)/g or next;
if ($digits[0] < 1900) {
warn "bad year $digits[0] for $file";
next;
}
$digits[0] -= 1900;
$digits[1] -= 1;
my $gmtime = timegm(reverse @digits);
if ($gmtime > time or $gmtime < time - 86400*90) {
warn "preposterous gmtime for $file: ", scalar gmtime $gmtime;
# next;
}
utime($gmtime, $gmtime, $file) or warn "Cannot utime on $file: $!";
}
Save it as datebyexif.pl
Usage:
./datebyexif.pl *.JPG
Download the datebyexif.pl script
Source: http://www.macosxhints.com/comment.php?mode=view&cid=83366
Posted by Hans-Henry Jakobsen
Move all files from directory dir into directories named by the original file extensions
exiftool '-Directory<datetimeoriginal>
Rename all images in dir according to the CreateDate date and time, adding a copy number with leading ‘-’ if the file already exists (%-c), and preserving the original file extension (%e).
Note the extra ‘%’ necessary to escape the filename codes (%c and %e) in the date format string.
exiftool '-FileName
Set the filename of all JPG images in the current directory from the CreateDate and FileNumber tags, in the form “20060507_118-1861.jpg”
exiftool '-FileName< ${CreateDate}_$filenumber.jpg' -d %Y%m%d dir/*.jpg
Adjust original date/time of all images in directory dir by subtracting one hour and 30 minutes.
exiftool -DateTimeOriginal-='0:0:0 1:30:0' dir
Posted by Hans-Henry Jakobsen