Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $data = 'V:\\games\\Art';
- $copy = 'V:\\games\\Art_{%}\\Art';
- $index = 0;
- $copied = 0;
- function traverse ($dir) {
- global $data, $copy, $index, $copied;
- $files = scandir($dir);
- foreach ($files as $row) {
- if (in_array($row, ['.', '..'])) {
- continue;
- }
- $file = "{$dir}\\{$row}";
- if (is_dir($file)) {
- traverse ($file);
- } else {
- if ($copied > 1000) {
- $copied = 0;
- $index++;
- }
- $_dir = dirname($file);
- $_copy = str_replace('{%}', $index, $copy);
- @mkdir(str_replace($data, $_copy, $_dir), 0777, true);
- copy($file, str_replace($data, $_copy, $file));
- echo "{$file} is copied.\r\n";
- $copied++;
- }
- }
- }
- traverse ($data);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement