m1/clearn.py
2020-04-17 11:37:13 +08:00

35 lines
915 B
Python

# -*- coding: utf-8 -*-
import os
import sys
import pdb
current_path = sys.argv[1]
remove_list = ('pyc', 'old', 'log1')
remove_files = []
def searchDirFile(rootDir, saveDir):
for dir_or_file in os.listdir(rootDir):
filePath = os.path.join(rootDir, dir_or_file)
if os.path.isfile(filePath):
if os.path.basename(filePath).endswith() in remove_list:
print('imgBox fileName is ' + os.path.basename(filePath))
remove_files.append(os.path.join(rootDir, filePath))
else:
continue
elif os.path.isdir(filePath):
searchDirFile(filePath, saveDir)
else:
print('not file and dir ' + os.path.basename(filePath))
remove_files = searchDirFile(current_path, remove_files)
pdb.set_trace()
print(f"{remove_files}") # if remove_files:
# for item in remove_files:
# os.remove(item)