#删除以._和__M开头的文件夹
import os
import shutil
def del_file(path):
for root, dirs, files in os.walk(path):
for name in dirs:
if name.startswith(‘._’) or name.startswith(‘__M’):
shutil.rmtree(os.path.join(root, name))
print(‘删除文件夹:’, os.path.join(root, name))
else:
print(‘保留文件夹:’, os.path.join(root, name))
if name == ‘main’:
path = input(‘请输入文件夹路径:’)
del_file(path)
print(‘删除完成’)