删除文件

This commit is contained in:
2023-09-23 18:07:45 +08:00
parent dd6f33ffc4
commit 847e66e949

23
dev.php
View File

@@ -1,23 +0,0 @@
<?php
// 递归处理多级目录extend\base\admin将所有以 Class.php 结尾的文件重命名为 Base.php
$dir = './extend/base/admin';
// 递归获取所有的文件
function scan_dir($dir)
{
$files = array_diff(scandir($dir), ['..', '.']);
foreach ($files as $file) {
if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) {
scan_dir($dir . DIRECTORY_SEPARATOR . $file);
} else {
if (str_ends_with($file, 'Class.php')) {
$file_path = $dir . DIRECTORY_SEPARATOR . $file;
$new_path = str_replace('Class.php', 'Base.php', $file_path);
rename($file_path, $new_path);
}
}
}
}
scan_dir($dir);