Created
November 6, 2015 08:25
-
-
Save cxymrzero/acd33a0c7786de2c9bbd to your computer and use it in GitHub Desktop.
将目录下所有文件替换成jpg格式
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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