widnows中的脚本不好用,所以投向Python,用Python协助工作,很好;
import os,sys
from stat import *import shutil
DelPathName = 'URelease'
def walktree(top, callback):
for f in os.listdir(top):
pathname = os.path.join(top, f)
mode = os.stat(pathname).st_mode
if S_ISDIR(mode):
if f == DelPathName:
walktree(pathname, removefile)
print 'remove dir: ', pathname
shutil.rmtree(pathname)
else:
walktree(pathname, visitfile)
elif S_ISREG(mode):
callback(pathname)
else:
print 'Skipping %s'%pathname
def visitfile(file):
print 'visiting: ',file
def removefile(file):
print 'remove file :', file
os.remove(file)
if __name__ == '__main__':
walktree('./', visitfile)#删除当前目录及子目录中的某些文件