Last active
August 29, 2015 14:20
-
-
Save coquer/22f2f2c14bffd1da8c77 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 | |
function blobR($pattern, $flags){ | |
$files = glob($pattern, $flags); | |
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir){ | |
$files = array_merge($files, blobR($dir.'/'.basename($pattern), $flags)); | |
} | |
return $files; | |
} | |
function copyfiles($pattern, $des_dir, $flags = 0){ | |
createdir($des_dir); | |
$arr = blobR($pattern, $flags); | |
foreach ($arr as $key => $value) { | |
$file = getfilename($value); | |
copy($value, $des_dir . '/' . $file); | |
} | |
} | |
function getfilename($filename){ | |
$file = substr($filename, strrpos($filename, '/') + 1); | |
return $file; | |
} | |
function createdir($des_dir){ | |
if (!file_exists($des_dir)) { | |
mkdir($des_dir, 0777, true); | |
} | |
} | |
copyfiles('*.epub', 'allbooks'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment