Skip to content

Instantly share code, notes, and snippets.

@shmshd
shmshd / move.php
Last active June 29, 2017 09:16 — forked from baamenabar/move.php
PHP move all files and folders from one directory to a new directory
<?php
$dir = "."; //path to backup
$dirNew = "move"; //path to move the destination
if(!file_exist($dirNew){
mkdir($dirNew, 0777, true); //create a new directory if not exist
}
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {