-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclear.py
More file actions
41 lines (38 loc) · 1.25 KB
/
clear.py
File metadata and controls
41 lines (38 loc) · 1.25 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
import glob
import os
import shutil
dirs = ['past_games', 'logs', 'models']
exclude = []
exclude_proj = []
exclude_dirs = []
dirs = list(set(dirs).difference(exclude_dirs))
delete_all = input(f"Do you want to delete all files: ").lower()
delete_all = delete_all == "y" or delete_all == "yes"
bkup = False
if not delete_all:
bkup = input(f"Do you want to bkup all files: ").lower()
bkup = bkup == "y" or bkup == "yes"
if bkup:
name = input("Where do you want to save it: ")
else:
name = None
for directory in dirs:
files = [f for f in glob.glob(f"{directory}/*", recursive=True)]
to_exclude = [f"{directory}\\{path}" for path in exclude]
files = list(set(files).difference(to_exclude))
exclude_files = []
for file in files:
for project in exclude_proj:
if project in file:
exclude_files.append(file)
files = list(set(files).difference(exclude_files))
delete = True # input(f"Do you want to delete all files in {directory}: ").lower() == 'yes'
if bkup:
shutil.move(f"{directory}", f"bkup/{name}")
if delete_all:
for file in files:
if os.path.isfile(file):
os.remove(file)
else:
shutil.rmtree(file)
os.system("cls")