Reputation: 40499
I have a rather simple perl script that boils down to
use warnings; use strict;
use File::Copy;
# ... some uninteressing things such as
# assigning variables etc ...
move($dir_from, $dir_to) or die "could not move $dir_from to $dir_to";
# ... more uninteresting things ...
This seems to work if $dir_1
and $dir_2
are on the same drive. But as soon as I try to move the directories accross drives, it won't work. Unfortunatly, I didn't find anything relating to that problem in the documentation of File::Copy
. In fact, the documentation even states that
If possible, move() will simply rename the file. Otherwise, it copies the file to the new location and deletes the original.
Can someone confirm that my "problem" is indeed related to my assumption or is there another cause?
Upvotes: 0
Views: 802
Reputation: 4581
Actually, the File::Copy
documentation does not state that it's able to move directories at all. The documentation just mentions files. Moving directories on the same partition "accidentally" works, because the rename()
function (which is preferred over doing a copy+delete if source and destination are on the same partition) works for both files and directories.
BTW, the behavior is the same on Unix systems.
If you need a move which is working on directories, then look at CPAN modules like File::Copy::Recursive
or File::NCopy
.
Upvotes: 4