Home > Backend Development > PHP Tutorial > Implementation code for batch replacement of file names in PHP_PHP tutorial

Implementation code for batch replacement of file names in PHP_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:26:43
Original
834 people have browsed it

The code is as follows:

Copy the code The code is as follows:

$dir = 'D:Program FilesresourceapplicationSkinPNG\';//Note here Path, you need to add two at the end. The first one represents the escape, but it is easy to encounter other specific escapes, so you need to judge carefully. It can be written as follows
$dir = 'D:/Program Files/resource/ application/Skin/PNG/';//If you write a path like this, you don't have to worry about escaping. The last one/don’t miss
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if ($file != "." && $file != "..")
{
if(filetype($dir . $file) == 'file')
{
$newfile = str_replace(array('_PNG','_XML','_ICO'),array('.PNG','.XML','.ICO'), $file);
var_dump($file .' =======> '.$newfile.'
');
rename($dir . $file, $dir . $newfile);
}
}
}
closedir($dh);
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323936.htmlTechArticleCopy the code as follows: $dir = 'D:Program FilesresourceapplicationSkinPNG\';//Pay attention to the path here , add two at the end, the first one means changing your mind, but this way...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template