使用python 编写代码 因为百度网盘下载的第二份文件里包含 (1). 只需要递归遍历删除所包含(1).的文件夹
一下是实现代码
python
import os
def delete_files_with_pattern(folder_path, pattern):
for root, dirs, files in os.walk(folder_path):
for file in files:
file_path = os.path.join(root, file)
if pattern in file:
try:
os.remove(file_path)
print(f"Deleted: {file_path}")
except Exception as e:
print(f"Error deleting {file_path}: {e}")
for dir_name in dirs:
dir_path = os.path.join(root, dir_name)
delete_files_with_pattern(dir_path, pattern)
# 替换为你要处理的文件夹路径
folder_to_process = "your_folder_path"
# 替换为你要查找并删除的文件名模式
pattern_to_delete = "(1)."
delete_files_with_pattern(folder_to_process, pattern_to_delete)