It all started out as a simple script to rename some files.
Now I can't find my way out!
I have several hundred files that are named like this:
'ENDPNA.PROD.HRBANS(EDIFACT)'
Note that the file name includes single ticks, dots, and parens.
Here's what I've done so far:
<snip>
while (<*>) { # select each source name in the directory
my $file = $_; # Set $file to the filename you just read
s#'.+\((.+)\)'#$1#; # cut out the part you want to keep (basename)
my $target = $_; # Set $target to the new file name
# Now build the full path of the destination directory...
$target = $DESTDIR . '/' . $target;
# Now escape the leading and trailing single quotes in the original
# file name ($file)
my $source = "\\";
$source .= $file;
$source =~ s#(.+)'#$1\\'#;
# my $source = quotemeta($file); #Using quotemeta to escape everything
#doesn't work either
#rename $source, $target or warn "$source: Cannot rename to $target: $!\n";
my @args = ("mv", "$source", "$target");
system(@args) == 0
or warn "$source: Cannot mv to $target: $!\n";
}
When I run this script, I get an error that says: A file or directory in
the path name does not exist.
Can someone please tell me what I'm doing wrong and/or suggest a better
way to do it?
Thanks!
richf
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]