Alte Dateien Löschen
Verfasst: Montag 15. April 2013, 19:25
Wer z.B. Einen bestimmten Ordner nach alten Datein durchcrawlen um diese zu löschen kann das mit folgendem Script machen (Funkt unter Linux und Windows):
Code: Alles auswählen
import sys, os, time
path="D:/DUMPS"
for root, subFolders, files in os.walk(path):
for file in files:
fullpath=os.path.join(root,file)
ftime = os.path.getmtime(fullpath)
print (fullpath)
print (ftime)
curtime = time.time()
difftime = curtime - ftime
if difftime > 604800: #1 Woche in sek.
os.remove(fullpath)
else:
print ("Probleme bei der Ausfuerung")
break
exit