我有一个删除整个目录的脚本,但我想修改它以删除除两个文件(kodi.log和)之外的所有内容,因此需要跳过kodi.old.log扩展名。.log
我的脚本是
TEMP = xbmc.translatePath(
'special://home/temp'
)
folder = TEMP
if os.path.exists(TEMP):
for the_file in os.listdir(folder):
file_path = os.path.join(folder, the_file)
try:
if os.path.isfile(file_path):
os.unlink(file_path)
elif os.path.isdir(file_path): shutil.rmtree(file_path)
donevalue = '1'
except Exception, e:
print e
任何想法将不胜感激。