On Wed, Oct 31, 2001 at 04:12:03PM -0500, Rich Fernandez wrote: Rearranged a bit for clarity.
First, your error: > When I run this script, I get an error that says: A file or directory in > the path name does not exist. This means that you tried to do something like: mv foo bar/foo where the directory 'bar' does not exist. Given your code, this must mean $DESTDIR doesn't exist. Keep in mind that, if you're using a relative path for $DESTDIR, it's going to be relative to your current working directory. The solution is to create the directory prior to moving your files into it. Now, as for your code... > 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"; rename will work better than mv, provided you're not trying to move files across filesystem boundaries, or perhaps rename directories. With rename you don't have to quote the filename, and you have better control over your diagnostic message. > my @args = ("mv", "$source", "$target"); > system(@args) == 0 > or warn "$source: Cannot mv to $target: $!\n"; A simpler way of saying this would be: system(@args) and warn "..."; Also, I'm not quite sure why you're storing these values in a temporary array that's only used once. > } Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]