菜单

PHP to rename all files under the file

2017年11月22日 - PHPer

When we use computer office, we need to rename all other files contained in a file. Because there are too many files, it’s more troublesome to change one by one. So what’s the good way to rename it at this time? The following article to share with you, through the PHP to achieve all the files included in the file rename, together to understand the implementation of the code

Rename rule is all spaces all replaced with “_”, and then add a “_s”.

<? PHP

$paths = “C://Documents and Settings//sk//Desktop//s//””;

$d = dir ($paths);

While (false! = = ($entry = $d-&gt); (read)) {

$table_change = array (‘=>’_’);

$newName = strtr ($entry, $table_change);

$newName = substr ($newName, 0, -4);

Rename ($paths.$entry, $paths.$newName. “_s.jpg”);

}

$d-> close ();

Echo “done””;

&gt?;

发表评论

电子邮件地址不会被公开。