docs: 优化多个 README 文件中的命令格式
- 移除了不必要的 mkdir 命令中的 && 符号 - 更新了 curl 命令格式,从 -fsSL 改为 -fSL - 添加了 Python 脚本说明文档 - 新增了删除空文件夹的 Python 脚本
This commit is contained in:
15
python/README.md
Normal file
15
python/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Python 脚本说明
|
||||
|
||||
## 删除空的文件夹
|
||||
|
||||
1. 下载脚本:
|
||||
|
||||
```bash
|
||||
curl -O https://i.sugarscat.cn/me/script/-/raw/main/python/delete_empty_folders.py
|
||||
```
|
||||
|
||||
2. 执行下载的脚本:
|
||||
|
||||
```bash
|
||||
python delete_empty_folders.py
|
||||
```
|
||||
17
python/delete_empty_folders.py
Normal file
17
python/delete_empty_folders.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import os
|
||||
|
||||
def delete_empty_folders(path='.'):
|
||||
# 倒序遍历所有文件夹,确保从最深层开始删除
|
||||
for root, dirs, files in os.walk(path, topdown=False):
|
||||
for dir_name in dirs:
|
||||
full_path = os.path.join(root, dir_name)
|
||||
try:
|
||||
# 检查是否为空文件夹
|
||||
if not os.listdir(full_path):
|
||||
os.rmdir(full_path)
|
||||
print(f"✅ 成功删除空文件夹: {full_path}")
|
||||
except Exception as e:
|
||||
print(f"❌ 无法删除: {full_path},错误: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
delete_empty_folders()
|
||||
Reference in New Issue
Block a user