forked from dosemu2/dosemu2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mknewyear
executable file
·64 lines (56 loc) · 1.15 KB
/
mknewyear
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
#! /usr/bin/perl
$newyear = "2014";
$filelistname = "";
$i = 0;
while ($ARGV[$i] ne "") {
if ($ARGV[$i] eq "-y") {
$i++;
if ($ARGV[$i] ne "") {
$newyear = $ARGV[$i];
$i++;
}
}
if ($ARGV[$i] eq "-f") {
$i++;
if ($ARGV[$i] ne "") {
$filelistname = $ARGV[$i];
$i++;
}
}
}
print "building file list ...\n";
if ($filelistname eq "") {
@files = `grep -l '(C) Copyright 1992,' \`find -type f -perm -u=w\``;
}
else {
@files = `grep -l '(C) Copyright 1992,' \`cat $filelistname\``;
}
print "...Ok, now processing\n";
$total = 0;
#foreach $i (@files) {print "$i";} exit;
foreach $i (@files) {
chop $i;
$total++;
print "processing $i\n";
open(FIN, "<$i") || die "Can't open $i";
open(FOUT, ">$i.new") || die "Can't open $i.new";
$changed_it = 0;
LINE: while (<FIN>) {
$line = $_;
if (/\(C\) Copyright 1992,[^0-9]+([0-9]+)\s+the\s+\"DOSEMU/) {
$line =~ s/$1/$newyear/;
$changed_it = 1;
}
print FOUT "$line";
}
close(FOUT);
close(FIN);
if ($changed_it) {
`mv $i.new $i`;
}
else {
`rm -f $i.new`;
$total--;
}
}
print "$total files converted\n";