in reply to Difficulties in copying directories from one network drive to another.
use File::Spec; use File::Copy; $folder1=File::Spec->catdir('//computerA','share','folder'); $folder2=File::Spec->catdir('//diffcomputer','share','new folder'); copy "$folder1/file.txt", "$folder2/new_file.txt" or die "Cannot copy +file.txt from $folder1 to $folder2. $!";
In that snippet, note the direction of the slashes for the computer name. It might seem backwards but it works. Also, using single quotes instead of double quotes means that the slashes won't get interpolated. And this does work, we do it all the time, every day in fact. All our scripts use UNC or absolute pathnames (Windows or Unix). What you may be running into is a problem with the space in the "other folder" name. Just a hunch, it causes us problems with some things unless we specially wrap double quotes around it to get it to work right. Hope that helps.
update: My mistake, I misread. I thought you were talking about files, not directories.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Difficulties in copying directories from one network drive to another.
by doowah2004 (Monk) on Sep 16, 2004 at 20:23 UTC |