-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
117 lines (93 loc) · 2.83 KB
/
main.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
from Rename import *
r = Rename()
#Get files
while True:
path = input("Enter folder path: ")
try:
r.SelectFiles(path)
except TooManyExtensions as TME:
print("TOO MANY EXTENSIONS FOUND", TME.ext)
continue
except (FileNotFoundError,OSError):
print("NO FILES FOUND")
continue
break
#Display Files
print("Files:")
for file in r.full_file_names:
print("\t" + file)
print()
#Choose option
while (True):
option = input("Enter option number:\n\t(0) Cancel\n\t(1) Replace text\n\t(2) Add text\n\t(3) Format text\n\t(4) Change extension\nEnter number: ")
if (option == "1"):
find = input("Enter text to find: ")
replace = input("Enter text to replace it with: ")
r.ReplaceText(find, replace)
elif (option == "2"):
text = input("Enter the text you wish to add: ")
placeBool = True
while (True):
placement = input("Do you fish to add text at start (1) or at end (2)?\n:\t")
if (placement == "1"):
placeBool = True
elif (placement == "2"):
placeBool = False
else:
print("Incorrect option")
continue
break
r.AddText(text, placeBool)
elif (option == "3"):
text = input("Enter the text you wish to format to: ")
starting_number = int(input("Starting number: "))
r.FormatText(text, starting_number)
elif (option == "4"):
new_ext = input("Enter the new extension: ")
r.ChangeExt(new_ext)
elif (option == "0"):
print("Exiting program")
quit()
break
else:
print("\nINCORRECT OPTION")
continue
break
#Preview changes
preview = input("Do you wish to preview the changes? (Y/N)\n:")
while True:
if (preview.lower() == "y"):
r.Preview()
elif (preview.lower() == "n"):
break
else:
preview = input("Incorrect option! (Y/N):\n:")
continue
break
#Commit changes
commit = input("\nDo you wish to commit these changes? (Y/N)\n:")
while True:
if (commit.lower() == "y"):
try:
r.Commit()
print("Done :)")
except DuplicationError:
print("Two or more files share the same new name")
elif (commit.lower() == "n"):
break
else:
commit = input("Incorrect option! (Y/N):\n:")
continue
break
#Revert changes
revert = input("\nDo you wish to revert these changes? (Y/N)\n:")
while True:
if (revert.lower() == "y"):
r.Revert()
print("Done :)")
elif (revert.lower() == "n"):
break
else:
revert = input("Incorrect option! (Y/N):\n:")
continue
break