Created
January 16, 2021 02:13
-
-
Save notcod/ca84bd39ab0fb47bcd31863631c23d56 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
| <?php | |
| // Get array of all source files | |
| $files = scandir("source"); | |
| // Identify directories | |
| $source = "source/"; | |
| $destination = "destination/"; | |
| // Cycle through all source files | |
| foreach ($files as $file) { | |
| if (in_array($file, array(".",".."))) continue; | |
| // If we copied this successfully, mark it for deletion | |
| if (copy($source.$file, $destination.$file)) { | |
| $delete[] = $source.$file; | |
| } | |
| } | |
| // Delete all successfully-copied files | |
| foreach ($delete as $file) { | |
| unlink($file); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment