如图,文件夹内3万多个txt文档,很多后面都是同名加1、2、3、4、5,许多的加到20,怎么把这些加序号的批量删除了
亲测可行
# 删除文件夹下(1).txt
import os
for root, dirs, files in os.walk(r"D:/deepLearning/py-demo/20210905/"):
for file in files:
if ("(" in file and ").txt" in file):
print('del... \t', file)
os.remove(os.path.join(root, file))
如有帮助,请采纳哦!