Created
August 29, 2015 17:30
-
-
Save ludioao/bf4b7351231b24761621 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$dir = "path/to/targetFiles"; | |
$dirNew = "path/to/destination/files"; | |
// Open a known directory, and proceed to read its contents | |
if (is_dir($dir)) { | |
if ($dh = opendir($dir)) { | |
while (($file = readdir($dh)) !== false) { | |
echo '<br>File: '.$file; | |
//exclude unwanted | |
if ($file==".") continue; | |
if ($file=="..")continue; | |
//if ($file=="index.php") continue; for example if you have index.php in the folder | |
if (rename($dir.'/'.$file,$dirNew.'/'.$file)) | |
{ | |
echo " Files Copyed Successfully"; | |
echo ": $dirNew/$file"; | |
//if files you are moving are images you can print it from | |
//new folder to be sure they are there | |
} | |
else {echo "File Not Copy";} | |
} | |
closedir($dh); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment