I'm trying to write a script that will automatically delete all the temp files in a specific folder, and I noticed that this script also deletes all the text files in that folder as well. Can anyone explain why it does that?
import os
path = 'C:\scripts27'
for root, dirs, files in os.walk(path):
for currentFile in files:
print "processing file: " + currentFile
extensions=('.tmp')
if any(currentFile.lower().endswith(ext) for ext in extensions):
os.remove(os.path.join(root, currentFile))
I'm running this script using Python 2.7.10 on a Windows 8.1 PC 64-bit.
Thanks!