-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuper-file.py
69 lines (59 loc) · 2 KB
/
super-file.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
from termcolor import colored
import os
while True :
ls = os.listdir(".")
ls_index = 0
for item in ls :
file_dir = ""
if os.path.isdir("./"+item) :
file_dir = colored(item,'green')
else :
file_dir = item
print (colored(str(ls_index) +") " , 'blue') + file_dir + "\n "
+colored("---------------------------------------------------------------"
, 'red'))
ls_index += 1
print("\n ")
print("you are in :" + colored( os.getcwd() , "yellow"))
print("what can i do for you\n")
print("change dir :1 // make dir : 2 // delete dir or file : 3 // "+
"\ncreate file : 4 // rename file or dir : 5\n")
user_cmd = int(input("type and click enter : "))
#cd
if user_cmd == 1 :
cd_cmd = input("number or just enter for privios dir :")
if not cd_cmd :
os.chdir("../")
else :
try:
value = int(cd_cmd)
os.chdir("./" +ls[value])
print(os.getcwd())
except ValueError:
print("Invalid integer '%s', try again" % (cd_cmd,))
#make dir
if user_cmd == 2 :
print("enter name of new dir , if you just enter we will name it new dir by default")
cd_cmd = input("name new dir : ")
if not cd_cmd :
os.mkdir("new dir")
else :
os.mkdir(cd_cmd)
#delete dir
if user_cmd == 3 :
cd_cmd = int(input("enter index of dir or file:"))
if os.path.isdir("."+ ls[cd_cmd]):
os.rmdir(ls[cd_cmd])
else:
os.remove(ls[cd_cmd])
print("removed")
#create file
if user_cmd == 4 :
cd_cmd = input("name file :")
os.system('touch '+ cd_cmd)
#rename file or dir
if user_cmd == 5 :
whichFile = int(input("rename which file or dir :"))
newName = input("new name :")
os.rename("./"+ls[whichFile],newName)
os.system('clear')