-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoveUnusedFiles.py
More file actions
43 lines (32 loc) · 1.09 KB
/
RemoveUnusedFiles.py
File metadata and controls
43 lines (32 loc) · 1.09 KB
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
import os
print("Type DEMO to do a simulation (wont change anything)")
print("Type YES to proceed\n")
choice = input("Choice: ")
# Newline because why not?
print()
excluded_files = [
"RemoveUnusedFiles.py",
]
excluded_extensions = [
"mp3"
]
for root, directories, files in os.walk("."):
for file in files:
# Checks for excluded extensions/files
if file in excluded_files: break
for excluded_extension in excluded_extensions:
if excluded_extension in file: break
# Removes the file if its in root
if os.path.isfile(file):
if choice == "DEMO":
print(f"File that would be deleted (root directory): {file}")
else:
os.remove(file)
# Else removes the file in its specific directory
else:
file_path = os.path.join(root, file)
if choice == "DEMO":
print(f"File that would be deleted: {file}")
else:
os.remove(file_path)
input("\nOK! Press ENTER to exit")