# -*- coding: cp936 -*-
#删除当前目录下所有子目录下所有指定扩展名的文件
import sys,os,glob,re
#配置1
array =("pdb","txt")
#程序开始
strRegex ="";
for i in range(len(array)):
strRegex = strRegex +r".*\."+array[i]+r"$"
if(i
strRegex +="|";
pattern = re.compile(strRegex)
for root,dirs,files in os.walk("./"):
for stringT in files:
match = pattern.match(stringT)
if match:
pathFile = os.path.join(os.path.abspath(root),stringT);
print(pathFile)
print("!!!!!!!!以上文件将被删除,强制关闭结束!!!!!!!!")
os.system("pause")
for root,dirs,files in os.walk("./"):
for stringT in files:
match = pattern.match(stringT)
if match:
pathFile = os.path.join(os.path.abspath(root),stringT);
buildCmd = 'del '+ pathFile
print(buildCmd)
if(1==os.system(buildCmd)):
print(r"del " + buildCmd + r" Failed" + "\n")
os.system("pause")
阅读(351) | 评论(0) | 转发(0) |