【发布时间】:2017-04-28 14:22:38
【问题描述】:
我正在尝试更改文件夹中的每个文件名,例如,如果文件名是 style.css,我想将其重命名为 style_[md5 value of style].css = style_a1b01e734b573fca08eb1a65e6df9a38.css
这是我尝试过的
if ($handle = opendir("D:/web/htdocs/extra/css/")) {
while (false !== ($fileName = readdir($handle))) {
$path_parts = pathinfo($fileName);
$newName = md5($path_parts['filename']);
rename($fileName, $newName);
}
closedir($handle);
}
我哪里错了?
错误是
Access is denied. (code: 5)
The system cannot find the file specified. (code: 2)
【问题讨论】:
-
为什么要这样做?如果你想强制缓存重新生成,还有比这更好的方法。
-
我只想做一次,因为我们有很多css和js文件
标签: php css file-rename batch-rename