-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunMe.py
More file actions
65 lines (45 loc) · 1.83 KB
/
RunMe.py
File metadata and controls
65 lines (45 loc) · 1.83 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
TEMPLATE = ""
DESCRIPTION = ""
AUTHOR = ""
def Inputs(*args):
global TEMPLATE, DESCRIPTION, AUTHOR
arg1 = input("Plugin Name:")
TEMPLATE = f"{arg1}"
arg2 = input("Plugin Description:")
DESCRIPTION = f"{arg2}"
arg3 = input("Plugin Author:")
AUTHOR = f"{arg3}"
def rename_folders_recursively(directory):
global TEMPLATE, DESCRIPTION, AUTHOR
for root, dirs, files in os.walk(directory):
for dir in dirs:
oldpath = os.path.join(root, dir)
if "{TEMPLATE}" in dir:
newpath = os.path.join(root, dir.replace("{TEMPLATE}", TEMPLATE))
os.rename(oldpath, newpath)
print(newpath)
for root, dirs, files in os.walk(directory):
for file in files:
oldpath = os.path.join(root, file)
if "{TEMPLATE}" in file:
newpath = os.path.join(root, file.replace("{TEMPLATE}", TEMPLATE))
os.rename(oldpath, newpath)
print(newpath)
print("Renaming references")
with open(newpath, 'r') as file:
data = file.read()
data = data.replace("{TEMPLATE}", TEMPLATE)
data = data.replace("{DESCRIPTION}", DESCRIPTION)
data = data.replace("{AUTHOR}", AUTHOR)
with open(newpath, "w") as file:
file.write(data)
print("Replaced references in: " + newpath)
Inputs()
print("--------SPECIFIED INPUTS---------")
print("Plugin Name: " + TEMPLATE)
print("Description: " + DESCRIPTION)
print("Author: " + AUTHOR)
print("--------RENAMING FILES---------")
rename_folders_recursively(os.path.dirname(os.path.realpath(__file__)))
print("--------RENAMING TEMPLATE IN FILES---------")