-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtag_write.pl
More file actions
executable file
·115 lines (97 loc) · 3.41 KB
/
tag_write.pl
File metadata and controls
executable file
·115 lines (97 loc) · 3.41 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/perl
# (jb) September 2009
use strict;
use FindBin '$Bin';
use File::Spec;
my $str_tag="Testtag";
my $str_tag_temp="Testtag";
my $int_tag_id;
my $int_i;
my $str_tag_file;
my @arr1= ();
my $item;
my $str_command;
my $taste;
my $output;
my $s1;
my $s2;
my $s3;
my $line;
########################################
# Einlesen der Text-Tags aus einem File.
########################################
$str_tag_file=File::Spec->catfile($Bin, "tags.txt");
print "Tag:\n";
open(IN, $str_tag_file) || die "$str_tag_file kann nicht gelesen werden.\n";
while (<IN>) {
chop;
push (@arr1, $_);
}
########################
# Ausgabe der Text-Tags.
########################
$int_i = 0;
foreach $item (@arr1) {
print $int_i.") $item\n";
$int_i++;
}
print "99) Comment-Tag löschen\n";
########################
# Auswahl des Text-Tags.
########################
print "Tag: ";
$int_tag_id = <STDIN>;
###############################
# Bei 99 Sonderfall, alle
# Comment-Tags löschen.
##############################
if ($int_tag_id == "99") {
foreach ( @ARGV ) {
$str_tag = "";
$str_command="exiftool -P -comment=\"".$str_tag."\" ".$_;
print $str_command."\n\n";
system($str_command);
}
exit 0;
} else {
# Andernfalls den Tag aus dem File nehmen.
$str_tag = $arr1[$int_tag_id];
}
foreach ( @ARGV ) {
#############################################################
# Tag auslesen und zwischenspeichern.
# Anschliessend anhaengen, wenn schon ein Tag existiert.
#############################################################
$output=`exiftool -P -p \'TAG,\$FileName,\$Comment' $_`;
if (-f $_) { # File?
print "$output";
($s1,$s2,$s3) = split(/,/,$output); # Tag von Comment und Filename trennen.
if ($s3) { # Nur anhaengen, wenn Comment schon was enthaelt.
chop($s3); # Letztes Zeichen abtrennen.
$str_tag = $s3.";".$str_tag; # Alter Inhalt + neuer Tag.
}
}
if (-d $_) { # Verzeichnis?
print "$output";
$str_tag_temp = $str_tag;
@arr1 = split(/\n/,$output); # Einzelzeilen der Ausgabe
foreach $line (@arr1) { # in Array speichern.
if ($line =~ /^TAG/) { # Wenn die Zeile mit TAG beginnt...
$str_tag = $str_tag_temp;
($s1,$s2,$s3) = split(/,/,$line); # Tag von Comment und Filename trennen.
if ($s3) { # Nur anhaengen, wenn Comment schon was enthaelt.
# chop($s3); # Letztes Zeichen abtrennen.
$str_tag = $s3.";".$str_tag; # Alter Inhalt + neuer Tag.
}
}
}
}
##############################################################
# Kommandozeile zum Schreiben zusammensetzen.
##############################################################
$str_command="exiftool -P -comment=\"".$str_tag."\" ".$_;
print $str_command."\n\n";
system($str_command);
}
$taste = <STDIN>;
exit 0;