-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebloat_desktop.py
94 lines (74 loc) · 2.33 KB
/
debloat_desktop.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
"""
To All Travelers, This Program is Great For Decluttering Your Desktop, HOWEVER
it deletes stuff. Make sure to finetune it to your needs before you let a random script you found
delete all your personal information.
Thank You!
"""
import os
import shutil
files = os.listdir()
#Files to Delete
toDelete = {"svg", "stl", "jar", "msi", "zip", "iso"}
#Files to Move to a Media Folder
moveToMedia = {"png", "jpg", "mp4", "mp3", "m4a", "jpeg", "webm", "ogg", "wav", "webp"}
#Files to Move to a Scripts Folder
moveToScripts = {"py", "ahk"}
#Files to Move to a Shortcuts Folder
moveToShortcuts = {"lnk", "Lnk"}
#Files to Move to an Apps Folder
moveToApps = {"exe"}
filesToSkip = {"scripts", "media", "folders", "shortcuts", "app", "debloat_desktop.py"}
if not os.path.exists("scripts"):
os.mkdir("scripts")
if not os.path.exists("media"):
os.mkdir("media")
if not os.path.exists("folders"):
os.mkdir("folders")
if not os.path.exists("shortcuts"):
os.mkdir("shortcuts")
if not os.path.exists("apps"):
os.mkdir("apps")
for file in files:
if file in filesToSkip:
continue
try:
os.rmdir(file)
continue
except Exception as e:
e
if os.path.isdir(os.path.join(os.path.abspath("."), file)):
try:
shutil.move(file, "folders")
continue
except Exception as e:
e
if file.split(".")[-1].lower() in toDelete:
try:
os.remove(file)
continue
except Exception as e:
e
if file.split(".")[-1].lower() in moveToMedia:
try:
shutil.move(file, "media")
continue
except Exception as e:
e
if file.split(".")[-1].lower() in moveToScripts:
try:
shutil.move(file, "scripts")
continue
except Exception as e:
e
if file.split(".")[-1].lower() in moveToShortcuts:
try:
shutil.move(file, "shortcuts")
continue
except Exception as e:
print(e)
if file.split(".")[-1].lower() in moveToApps:
try:
shutil.move(file, "apps")
continue
except Exception as e:
print(e)