6 # Created by Pierre Andrews on 01/07/2007.
7 # Copyright 2007 Pierre Andrews. All rights reserved.
9 #use lib "/usr/bin/lib/";
11 # add our 'lib' directory to the include list BEFORE 'use Image::ExifTool'
15 $exeDir = ($0 =~ /(.*)[\\\/]/) ?
$1 : '.';
16 # add lib directory at start of include path
17 unshift @INC, "$exeDir/lib";
29 my $exifTool = new Image
::ExifTool
;
30 my $pattern = $ENV{'pathPattern'};
32 $pattern = "%Y_%m_%d/";
34 $exifTool->Options(DateFormat
=> $pattern);
41 ($name,$dir,$suffix) = fileparse
($file,qr/\.[^.]*$/);
42 my $destPath = $ENV{'directoryPath'};
43 if(!$destPath) { $destPath = $dir; }
44 my $info = $exifTool->ImageInfo($file, 'DateTimeOriginal');
45 my $path = $$info{'DateTimeOriginal'};
46 if(!$path && $pattern !~ /%[A-Za-z]/) {
50 while($path =~ /:([a-zA-Z]+):/g) {
51 if($1 =~ /basename/i) {
53 $path =~ s/:basename:/$name/g;
54 } elsif($1 =~ /ext/i) {
55 $path =~ s/:ext:/$suffix/g;
57 my $info = $exifTool->ImageInfo($_, "$1");
69 $path =~ s/[^A-Za-z0-9_\/.-~]/_
/g
;
70 $path = $destPath.'/'.$path;
72 $homedir=`ksh -c "(cd ~ 2>/dev/null && /bin/pwd)"`;
74 $path =~ s/^~/$homedir/;
76 ($new_name,$new_dir,$new_suffix) = fileparse
($path,qr/\.[^.]*$/);
77 if($new_name && !$with_basename) {
78 $path = $new_dir.'/'.$new_name.$new_suffix;
81 $path .= $name.$suffix;
83 $new_suffix = $suffix;
85 if(!$new_suffix || $new_suffix!=$suffix) {
89 if(!$ENV{'test'}) { mkpath
($new_dir); }
90 if(!$ENV{'overwrite'}) {
92 if($path !~ /:cnt:/i) {
93 $path =~ s/(\.[^.]*)$/_:cnt:$1/;
97 $new_path =~ s/:cnt:/$local_cnt/g;
101 $new_path =~ s/:cnt:/$local_cnt/g;
106 $path =~ s/_:cnt://g;
110 if($ENV{'action'} == 'move') {