Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $imagefolder = "";
- $images = GLOB($imagefolder . "/" . "*{.jpg,.jpeg,.png,.gif}", GLOB_BRACE);
- foreach ($images as $img) {
- $file = $img;
- $fileparts = pathinfo($file);
- $path = $fileparts['dirname'] . "/newfiles/";
- $newfile = $path . date("Y-m-d", filemtime($img)) . "." . $fileparts['extension'];
- if (!file_exists($newfile)) {
- rename ($file, $newfile);
- $log = $path . "/log.txt";
- $data = "original file: {$file} to: {$newfile} status: Successful";
- } else {
- $data = "original file: {$file} to: {$newfile} status: Error, file exists";
- }
- file_put_contents($log, $data, FILE_APPEND); // create log file
- }
Add Comment
Please, Sign In to add comment