今天我有几千个文件要一次修改文件或把后缀名给改了,但是我要手工一个个去改,不得改几天后来想到一个办法,利用php写一个量修改文件名/文件后缀名程序,一下就实现了,下面来看看方法。
几个关键的函数。
is_dir($dirname) //判断一个文件名是否 为目录
opendir($dirname) //打开一个文件夹
readdir($dir_stream) //函数返回由 opendir() 打开的目录句柄中的条目
pathinfo($path) //函数以数组的形式返回文件路径的信息。
例如当前文件夹下的P1010436
例如当前文件夹下的P1010436.jpg文件路径信息数组:
Array
(
[dirname] => .
[basename] => P1010436.jpg
[extension] => jpg
[filename] => P1010436
)
rename(oldname,newname,context) //函数重命名文件或目录。若成功,则该函数返回 true。若失败,则返回 false。
代码如下 | 复制代码 |
function fileRename($dir,$srcExtension,$desExtension){ |
使用方法很简单,我们把图片与php文件同一目录然后再运行php即可。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool