tomcat
|
#t007.htm#,
HelloWorld.class,
HelloWorld.java,
TRANS.TBL,
backup5,
backup6,
backup7,
change_max.pl,
it006.html,
it007.html,
it008.html,
it009.html,
junk,
nup.pl,
onedown.pl,
oneup.pl,
t001.html,
t002.html,
t003.html,
t004.html,
t005.html,
t006.html,
t007.html,
t008.html,
t009.html,
t010.html,
t011.html,
t012.html,
t013.html,
t014.html,
t015.html,
t016.html,
t017.html,
t018.html,
t019.html,
t020.html,
t021.html,
t022.html,
t023.html,
t024.html,
t025.html,
t026.html,
t027.html,
t028.html,
t029.html
|
|
|
#!/usr/bin/perl
if($#ARGV < 0) {
die "Usage: onup.pl [dir] nameNNNN.html\n";
}
elsif ($#ARGV == 0) {
$dir = ".";
$file = $ARGV[0];
}
elsif ($#ARGV == 1) {
$dir = $ARGV[0];
$file = $ARGV[1];
}
if($file =~ /^([a-z]+)(\d+)\.html$/) {
$fname = $1;
$fnumber = $2;
}
else {
die "cannot parse file name $file";
}
$numlen = length($fnumber);
$format = "%0" . $numlen . "d";
opendir(DIR, $dir) || die "Cannot open directory $dir for reading\n";
$maxnum = 0;
while($entry = readdir(DIR)) {
if($entry =~ /^$fname(\d+)\.html$/ ) {
print STDOUT "$entry\n";
if($1 > $maxnum) {
$maxnum = $1;
}
}
}
for ($i = $maxnum; $i >= $fnumber; $i--) {
$from = $dir . "/" . $fname . sprintf($format, $i) . '.html';
$to = $dir . "/" . $fname . sprintf($format, $i+1) . '.html';
system("mv $from $to");
print STDOUT "Moved file $from, to file $to\n";
}
|