-
Notifications
You must be signed in to change notification settings - Fork 0
/
delet.py
73 lines (53 loc) · 1.84 KB
/
delet.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
import projectsmanager
import time
import os
import json
import shutil
import colorama
from colorama import Fore, Back, Style
from colorama import init
init()
bg = Back.BLUE
r = Back.BLACK
br = Back.RED
fg = Fore.GREEN
fr = Fore.WHITE
def remove():
print("DELETE METHOD")
print("Folder -F or file -f ?")
way = str(input("> "))
if way == "-F":
parent_dir = str(input("Parent dir: "))
path = os.path.join(parent_dir)
isExist = os.path.exists(path)
if isExist == False:
print(br + "/!\ This folder/dir doesn't exist.")
projectsmanager.menu()
else:
shutil.rmtree(path)
#s = str(input(""))
time.sleep(2)
if way == '-f':
directory = str(input("Folder name:"))
if directory == "None" or directory == "-n":
parent_dir = str(input("Parent dir: "))
path = os.path.join(parent_dir)
isExist = os.path.exists(path)
else:
parent_dir = str(input("Parent dir: "))
path = os.path.join(parent_dir, directory)
isExist = os.path.exists(path)
if isExist == False:
print(br + "/!\ This folder/dir doesn't exist.")
projectsmanager.menu()
else:
print(fg + "Which files you want to delete ?" + fr)
print(os.listdir(path))
filedel = str(input("filename.ext > "))
if filedel == "-n" or filedel == "None":
projectsmanager.menu()
else:
os.remove(path + "\\" + filedel)
#s = str(input(""))
print(fg + "File(s) / Folder(s) successfully deleted." + fr)
projectsmanager.menu()