
<?php
//定义生成器提升性能
function generate($path)
{
$list = scandir($path);
if(is_null($list) || empty($list)) {
return null;
}
foreach($list as $k=>$v){
yield $v;
}
}
function multi($path)
{
$value = generate($path);
if(is_null($value)){
return;
}
//使用正则修改文件名
$regexp = "/【.*?】/";
foreach($value as $k => $v){
if(!in_array($v,[".","..",__FILE__])){
$new = preg_replace($regexp,"",$v);
//windows目录下使用斜线
rename($path."\".$v,$path."\".$new);
if(is_dir($path."\".$new)){
multi($path."\".$new);
}
}
}
}
multi(__DIR__);
hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 »
批量递归修改文件夹名或文件名