C
Chad
I am still trying to learn perl. I know there are basic rename scripts
out there, but I am trying to make one as a learning tool.
The script should take a directory from the prompt and make a renamed
copy in the same directory replacing spaces with underscores. It seems
to do everything except the actual file copy.
It's not that I need this program. Instead I would be gratefull for
any insight and undestanding as to why it does not work.
Thank you
Chad
---
#!/usr/bin/perl
use File::Copy;
$output = `cmd 2>&1`; #trying to see errors
$olddirname = $ARGV[0];
$newdirname = "$olddirname.new";
opendir(DirNameold,"$olddirname") or die "could not open
directory:$olddirname";
while (defined($file = readdir DirNameold )) {
$newfilename = $file;
$newfilename =~ tr/ /_/;
copy("$file","$newfilename") unless $file eq $newfilename;
};
---
out there, but I am trying to make one as a learning tool.
The script should take a directory from the prompt and make a renamed
copy in the same directory replacing spaces with underscores. It seems
to do everything except the actual file copy.
It's not that I need this program. Instead I would be gratefull for
any insight and undestanding as to why it does not work.
Thank you
Chad
---
#!/usr/bin/perl
use File::Copy;
$output = `cmd 2>&1`; #trying to see errors
$olddirname = $ARGV[0];
$newdirname = "$olddirname.new";
opendir(DirNameold,"$olddirname") or die "could not open
directory:$olddirname";
while (defined($file = readdir DirNameold )) {
$newfilename = $file;
$newfilename =~ tr/ /_/;
copy("$file","$newfilename") unless $file eq $newfilename;
};
---