PHP – Directory Mover

The given PHP example can move a directory from one location to another location.

Code Example:
$newDir="d:\dirnew"; // Destination to move 
$oldDir="c:\dirold"; //Dir to move 

function dirmover($oldDir,$newDir){ 
@mkdir($newDir) or die("Directory already exists."); 
$dir=@opendir($oldDir) or die("Invalid directory."); 
    if(($file!='.') && ($file!='..')) 
        @copy($oldDir."\\".$file,$newDir."\\".$file) or die("Unable to copy file :$file."); 
        @unlink($oldDir."\\".$file) or die("Unable to remove file :$file."); 

Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail

Leave a Comment

Your email address will not be published. Required fields are marked *