in reply to Moving directories

If I understand what you're asking--and it's quite possible that I don't :)--File::Copy should work just fine for your needs:
use File::Copy; move("dir1", "dir2");
... I'm not sure if this is OS-dependent or not. My File::Copy::move first tries to use rename to move the directory. Looking at the rename docs, I see:
Other restrictions include whether it works on directories...
You might just try it out and see if it works. Have you tried that?

Replies are listed 'Best First'.
RE: Re: Moving directories
by Anonymous Monk on Jun 27, 2000 at 11:08 UTC
    <KBD>> move("dir 1", "dir2");</KBD>

    Up to now I've written only wimpy little scripts (aside from that replacement for getopts :)
    and have had no occasion to use file::copy...until a couple of minutes ago.

    It worked as advertised given the suggestion quoted above (same drive). It failed
    ("Permission denied") if the destination was a not-yet-created directory on another drive.

    It didn't error out--but still didn't move anything--when the destination directory,
    on another drive, existed at the time the command was given.

    The friend gave few details in his e-mail but I'm guessing he wants to move entire trees
    from one drive to another.

      If you want to move whole trees then you could do something using File::Find. Something like this perhaps (untested)

      use File::Find; use File::Copy; my $src = '/some/directory/'; my $tgt = '/some/other/directory/'; find($src, \&move_it); sub move_it { if (-d $File::Find::name) { $File::Find::name =~ s/$src/$tgt; mkdir $File::Find::name, 0777 unless -d $File::Find::name; } else { my $new = $File::Find::name; $new =~ s/$src/$tgt; copy($File::Find::name, $new); } }
      --
      <http://www.dave.org.uk>

      European Perl Conference - Sept 22/24 2000
      <http://www.yapc.org/Europe/>