#1
  1. No Profile Picture
    Simon Rickell
    Guest
    Devshed Newbie (0 - 499 posts)
    Can anyone tell me how I can move files
    between directories with Perl?
  2. #2
  3. No Profile Picture
    moderator
    Guest
    Devshed Newbie (0 - 499 posts)
    This may help, it is taken from the "Camel Book":

    Rename
    rename OLDNAME, NEWNAME
    This function changes the name of a file. It returns 1 for success, 0 otherwise (and puts the erroro code into $!). It will not work across filesystem boundaries. If there is already a file name NEWNAME, it will be destroyed.

    Thus you could use something as follows:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    #!/usr/bin/perl

    $oldfile='/home/name1/old_file.txt';
    $newfile='/home/name2/new_file.txt';

    rename $oldfile, $newfile;
    [/quote]

    [This message has been edited by moderator (edited 07-27-99).]

IMN logo majestic logo threadwatch logo seochat tools logo