|
#!/usr/bin/perl
my $jpath = "";
local $jrtempfile = "D:\\util\\jr.tmp";
my @files = read_dir($jpath);
foreach $afile (@files) {
if($afile eq "") {
}
else {
#print "JIN:$afile:\n";
my $bfile = $afile;
$bfile =~ s/\[abc\]/\[a b c\]/g;
#$bfile =~ s/\[a b c\]/\[abc\]/g;
if($afile eq $bfile) {}
else {
#print "move \"$afile\" \"$bfile\"";
system("move \"$afile\" \"$bfile\"");
}
}
}
sub read_dir {
my ($jpath) = @_;
my @lists = "";
system("dir $jpath > $jrtempfile");
open(IN,"$jrtempfile");
my @files =<IN>;
close(IN);
system("del $jrtempfile");
foreach $afile (@files) {
my ($fname,$fext,$fsize,$fdate,$ftime,$flname)
= &read_dirline($afile);
#print "O:$fname:$fext:$fsize:$fdate:$ftime:$flname:\n";
if(! $fname) {
#rint " ...Nothing...\n";
}
elsif($fname =~ /^\./) {
#rint ".:$fname:$fext:$fsize:$fdate:$ftime:$flname:\n";
}
elsif($fsize =~ /\<DIR\>/) {
#rint "D:$fname:$fext:$fsize:$fdate:$ftime:$flname:$jpath:\n";
}
else {
#rint "F:$fname:$fext:$fsize:$fdate:$ftime:$flname:$jpath:\n";
push(@lists,$flname);
}
}
return @lists;
}
sub read_dirline {
my ($dirline) = @_;
chop($dirline);
if($afile =~ /^\s/) {
return ();
}
else {
my @abc = split('',$dirline,13);
my $fname = join('',@abc[0..7]);
$fname =~ s/\s//g;
my $fext = join('',@abc[9..11]);
$fext =~ s/\s//g;
$abc[12] =~ s/^[\s]+//g;
my ($fsize,$fdate,$ftime,$flname) = split(/[\s]+/,$abc[12],4);
return($fname,$fext,$fsize,$fdate,$ftime,$flname);
}
} |
|