Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Posts
    310
    Thanks
    86
    Thanked 3 Times in 3 Posts

    Move files from one directory to another

    Hello All,

    Hoping someone can kindly help.

    I'm looking to move any files from one directory (parsers) to another (complete). Now i've tried two ways

    PHP Code:

    <?

    /* Set the path details  */
    $path '/home/*******/parsers/test/parse/'//Directory which I read from 
    $complete '/home/*******/parsers/test/complete/'//Directory which I wish to place into 
    $dir opendir($path); 

    while (
    false !== ($file readdir($dir))) { 
       
        
    rename("$path/$file""$complete/$file"); 



    ?>
    But this way errors:

    home/cfpdigi/*******/test/parse//.,/home/*******/parsers/test/complete//.) [function.rename]: Device or resource busy


    and this way...

    PHP Code:

    <?

    /* Set the path details  */
    $path '/home/*******/parsers/test/parse/'//Directory which I read from 
    $complete '/home/*******/parsers/test/complete/'//Directory which I wish to place into 
    $dir opendir($path); 

        
    rename("$path/$file""$complete/$file"); 

    ?>
    Moves file to 'complete' but then completely deletes the 'parse' folder, when I want the 'parse' folder to remain in place, but just have it's contents moved to 'complete'?

    Anyone help?

    Thanks

  • #2
    Regular Coder ahayzen's Avatar
    Join Date
    Jun 2009
    Posts
    110
    Thanks
    8
    Thanked 11 Times in 11 Posts
    Hi stfc_boy

    That doesn't look like HTML or CSS. Did you post this in the wrong section?
    if so please move to the relevant section.

    Andy

  • #3
    Banned
    Join Date
    Jul 2010
    Posts
    66
    Thanks
    0
    Thanked 1 Time in 1 Post
    hi check this If the destination file already exists, it will be overwritten.

    $file = 'example.txt';
    $newfile = 'example.txt.bak';

    if (!copy($file, $newfile)) {
    echo "failed to copy $file...\n";
    }

    Hope this helps

    Thanks and Regards
    santhosh


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •