I've been developing window services using python (win32api), and often I find is necessary that I need to clean up files at the end of the process. I developed a small function that is quite helpful for cleaning up files by extension:
def cleanUpFiles(directory,extension):
dir = directory
files = os.listdir(dir)
for f in files:
if not os.path.isdir(f) and extension in f:
os.remove(dir + os.sep + f)
Enjoy