Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Is this possible, or would I have to create a new one and move the files, if so how.

Replies are listed 'Best First'.
Re: Renaming Direcotries
by davis (Vicar) on Jun 26, 2002 at 16:13 UTC
    You could move the directory wholesale from the shell, as in
    $>mv old_name new_name
    If you're on *nix.

    If you're bent on a Perl solution - use the portable (and already installed) File::Copy module.
    Ripped verbatim from File::Copy's POD:

    use File::Copy; copy("file1","file2"); copy("Copy.pm",\*STDOUT);' move("/dev1/fileA","/dev2/fileB");
    Obviously, you'll want the move() function.

    Incidentally, you may wish to try typing "Renaming" in the search box at the top of every page next time.

    Update: Whoops. I missed the fact that you could do a straight rename("OLDNAME", "NEWNAME"); My bad
    Update 2: Aristotle++ Don't use the rename() - its abilities vary from system to system. read

    perldoc -f rename
    for the full info.

    cheers
    davis
    Is this going out live?
    No, Homer, very few cartoons are broadcast live - it's a terrible strain on the animator's wrist

      I missed the fact that you could do a straight rename("OLDNAME", "NEWNAME");
      Careful. That will not work across filesystems. Otherwise, ++

      Makeshifts last the longest.

      One concern that no one has mentioned yet:
      Error Checking:

      1. Check to make sure you're not going to clobber an existing file or directory
      2. Is the file that is renamable movable?
      3. Is the directory that you'll be working in writable?
      4. etc...
      Check your results and what you're planning to do, otherwise you might have some tedious devugging to do.