Return to Snippet

Revision: 17902
at September 16, 2009 14:15 by el-artiste

Initial Code
      $root = $_GET['root'];
      $files = array_merge(glob("$root*.*"),glob("$root*\*.*"),glob("$root*\*\*.*"));
      for($i=0;$i<count($files);$i++) {
      if(stripos($files[$i],"Thumbs.db")) {
      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";
      echo "$x image files renamed. $z Thumbs.db files deleted.";

Initial URL

Initial Description
This snippet is just an upgrade to the "" 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