Skip to content

Instantly share code, notes, and snippets.

@cxymrzero
Created November 6, 2015 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cxymrzero/acd33a0c7786de2c9bbd to your computer and use it in GitHub Desktop.
Save cxymrzero/acd33a0c7786de2c9bbd to your computer and use it in GitHub Desktop.
将目录下所有文件替换成jpg格式
<?php
$dir = opendir("images");
$dirname = dirname(__FILE__) . '\images';
echo $dirname;
while(($file = readdir($dir)) !== false) {
if ($file!='.' and $file!='..') {
echo "filename: {$file}\n";
$newFilename = substr_replace($file, 'jpg', -3, 3);
rename($dirname . "\\" . $file, $dirname . "\\" . $newFilename);
}
}
closedir();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment