This repository has been archived on 2026-06-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
EDT/admin/debug/rename/index.php
T
wsh5485 7e47ce238b chore: 添加多个图片和资源文件
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
2025-06-15 13:04:37 +08:00

38 lines
887 B
PHP

<?php
//-------------------------------------------------------重命名单款图片的名字
error_reporting(E_ERROR | E_WARNING | E_PARSE);
//使用方法:程序和old,new目录放到可执行php的地方,old文件夹放需要命名的图片,命名好的图片会生成在new文件夹
$olddir="old";
$newdir="new";
$d=dir($olddir);
$i=1;
while($a=$d->read()){
if(is_file($olddir.'/'.$a) && ($a!='.') && ($a!='..')){
$f=$a;
//后缀名自动重命名
$img_info=getimagesize($olddir."/".$f);
$arr1=explode(".",$f);
if($img_info["mime"]=="image/png"){
$f1=$arr1[0].".png";
}else if($img_info["mime"]=="image/gif"){
$f1=$arr1[0].".gif";
}else{
$f1=$f;
}
echo $i.":".$f."|".$img_info["mime"]."|".$f1."<br>";
//*/
/*
//自动处理中斜杠
if(strpos($f,"-")){
$f1=str_replace("-","_",$f);
}else{
$f1=$a;
}
echo $f."|".$f1."<br>";
*/
copy($olddir."/".$f,$newdir."/".$f1);
$i++;
}
}
$d->close();
?>