Revision: 17902
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 16, 2009 14:15 by el-artiste
Initial Code
<?php $root = $_GET['root']; $files = array_merge(glob("$root*.*"),glob("$root*\*.*"),glob("$root*\*\*.*")); $z=0; $x=0; for($i=0;$i<count($files);$i++) { if(stripos($files[$i],"Thumbs.db")) { unlink($files[$i]); $z++; } else { $ext = strtolower(substr($files[$i],strlen($files[$i])-3,3)); if (preg_match("/(jpg|gif|png|bmp)/",$ext)) { $filename = substr($files[$i],0,strlen($files[$i])-3); $newfile = $filename.$ext; echo $ext."\n"; rename($files[$i],$newfile); $x++; } } } echo "$x image files renamed. $z Thumbs.db files deleted."; ?>
Initial URL
Initial Description
This snippet is just an upgrade to the "http://snipplr.com/view/7396/php-file-extension-case-changer/" code. This particular code works on image files... although you can just change this line [if (preg_match("/(jpg|gif|png|bmp)/",$ext)) ] to target a specific filetype. ciao! hope this piece of code can help you as it has helped me. :)
Initial Title
Code to change the file extensions of images to lowercase
Initial Tags
file, code, images
Initial Language
PHP