How to traverse the folder and modify the file name in the folder in php

藏色散人
Release: 2023-03-10 13:34:02
Original
1893 people have browsed it

How to traverse a folder and modify the name of the file in the folder: first read the folder; then traverse the folder through the "foreach($temp as $v){...}" method; finally pass The "@rename($a,$new_name);" method can be used to modify the file name.

How to traverse the folder and modify the file name in the folder in php

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

How does php traverse the folder and modify the files under the folder? Name?

php traverses the folder file name and changes the file name

$a","
"; //把文件夹红名输出 list_file($a);//因为是文件夹所以再次调用自己这个函数,把这个文件夹下的文件遍历出来 }else{ echo $a."
"; $info = pathinfo($a); //$file_name = basename($a,'.'.$info['extension']); $kuozhan=$info["extension"]; $lujing=$info["dirname"]; $mingcheng=$info["filename"]; if($mingcheng!="4" and $mingcheng!="5"){ $mingcheng_new=base64_encode($mingcheng); $new_name=$lujing."/".$mingcheng_new.".".$kuozhan; @rename($a,$new_name); } //var_dump($info); //echo "*****".$file_name; } } } list_file('F:/MYOA'); ?>
Copy after login

[Recommended learning:PHP video tutorial]

The above is the detailed content of How to traverse the folder and modify the file name in the folder in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!