1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/perl
# - Aenderung von File laut Infos von Tool "exiftool" in "Exif_Ort"
# Beispiel : mv P1000041.JPG 0004_Opera_Plaza-San_Francisco.JPG
use File::Copy;
use File::Spec;
use File::Basename;
use Image::ExifTool ;
use File::Find;
if( $#ARGV == -1)
{
print STDERR "Usage: $0 <Directory>\n";
exit 1;
}
my $bild_dir = $ARGV[0] or die "Must specify Directory.\n";
my $exifTool = new Image::ExifTool;
my $exifTool_dir = "/cygdrive/f/ProgrammePriv/GPS/Exiftool/Image-ExifTool-8.65";
my $exifTool_prog = "$exifTool_dir/exiftool";
my $i=1;
if( -d $bild_dir )
{
find(\&dir_all, $bild_dir);
sub dir_all
{
my $filename = File::Spec->catfile($File::Find::name);
if( -e $filename )
{
if (/^.*JPG\z/s )
{
print("File(Gefunden): $filename\n");
my $file_basename = File::Basename::basename (File::Spec->catfile($filename) );
# @tags = $exifTool->GetTagList($info, 'Group0');
# my $thumbInfo = $exifTool->ImageInfo ($$info{ThumbnailImage});
# -s[NUM] (-short)
# Short output format. Prints tag names instead of descriptions.
# Add NUM or up to 3 -s options for even shorter formats:
#
# -s1 or -s - print tag names instead of descriptions
# -s2 or -s -s - no extra spaces to column-align values
# -s3 or -s -s -s - print values only
# Also effective when combined with -t, -h, -X or -listx options.
# Test-Aufruf : UNIX: ls my $value = qx(ls);
# print $value;
#my $orts_teil = system("$exifTool_prog -s3 -Sub-location \"$filename\"");
my $orts_teil = qx($exifTool_prog -s3 -Sub-location \"$filename\");
print "orts_teil : $orts_teil\n";
$orts_teil =~ s/ /_/;
my $ort = qx($exifTool_prog -s3 -City \"$filename\");
print "ort: $ort\n";
$ort =~ s/ /_/;
my $i_fmt = printf "%04d",$i;
# Ort vorhanden in EXIF Daten
if ( defined($ort) )
{
if ( $ort eq $orts_teil )
{
$new_file=$bild_dir."/".$i_fmt."_".$ort.".JPG";
}
else
{
$new_file=$bild_dir."/".$i_fmt."_".$ort."_".$orts_teil.".JPG";
}
}
else
{
$new_file=$bild_dir."/".$i_fmt."_".$file_basename;
}
if( -e $new_file )
{
print "File schon vorhanden $new_file";
}
else
{
print "mv $filename $new_file";
}
}
}
$i++;
}
}
else
{
print("Dir: $bild_dir nicht gefunden \n");
}