Der lästige Windowsmüll mit einem Schlag wech.
Gruss, Seven
Code: Alles auswählen
# -*- coding: iso-8859-1 -*-
'''
Befreit Windows-XP von temporärem Datenmüll
'''
import win32con, win32api,os
tempinternetpath = 'C:/Dokumente und Einstellungen/xx/Lokale Einstellungen/Temporary Internet Files'
temppath = 'C:/Dokumente und Einstellungen/xx/Lokale Einstellungen/Temp/'
cookiespath = 'C:/Dokumente und Einstellungen/xx/Cookies/'
zuletztverwendet = 'C:/Dokumente und Einstellungen/xx/Recent'
#--------------------------------------- Temporary Internet Files -----------------------------------------
win32api.SetFileAttributes(tempinternetpath, win32con.FILE_ATTRIBUTE_NORMAL) # Dateiattribut auf 'normal' setzen
allefiles = os.listdir(tempinternetpath + '/')
for af in allefiles:
if os.path.isfile(tempinternetpath + '/' + af): # Check ob File
try:
os.remove(tempinternetpath + '/' + af) # Temporary Internet Files löschen
except:
pass
win32api.SetFileAttributes(tempinternetpath,win32con.FILE_ATTRIBUTE_HIDDEN) # Dateiattribut auf 'versteckt' setzen
#------------------------------------------------- Temp -----------------------------------------------------
allefiles = os.listdir(temppath)
for af in allefiles:
if os.path.isfile(temppath + af):
try:
os.remove(temppath + af) # Temp-Files löschen
except:
pass
#------------------------------------------------ Cookies ---------------------------------------------------
allefiles = os.listdir(cookiespath)
for af in allefiles:
if af <> 'index.dat':
if os.path.isfile(cookiespath + af):
try:
os.remove(cookiespath + af) # Cookies löschen
except:
pass
#----------------------------------- zuletzt verwendete Dokumente ---------------------------------------
win32api.SetFileAttributes(zuletztverwendet, win32con.FILE_ATTRIBUTE_NORMAL)
allefiles = os.listdir(zuletztverwendet + '/')
for af in allefiles:
if os.path.isfile(zuletztverwendet + '/' + af):
try:
os.remove(zuletztverwendet + '/' + af) # 'Zuletzt verwendete Dokumente' - Ordner leeren
except:
pass
win32api.SetFileAttributes(zuletztverwendet,win32con.FILE_ATTRIBUTE_HIDDEN)