PHP: rename all files to lower case in a directory recursively

烂漫一生 提交于 2019-12-03 16:44:24

You can use the SPL's RecursiveDirectoryIterator for that.

<?php
$path = realpath('your/path/here');

$di = new RecursiveIteratorIterator(
    new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS),
    RecursiveIteratorIterator::LEAVES_ONLY
);

foreach($di as $name => $fio) {
    $newname = $fio->getPath() . DIRECTORY_SEPARATOR . strtolower( $fio->getFilename() );
    echo $newname, "\r\n";
    //rename($name, $newname); - first check the output, then remove the comment...
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!