-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
37 lines (34 loc) · 1.7 KB
/
test.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
import os
dir = r"C:\Users\jiang-laptop\Downloads\test"
listDir = os.listdir(dir)
for fileName in listDir:
origName = os.path.join(dir, fileName)
replName = os.path.join(dir, fileName.lower()).replace("_", " ")
replName = replName.replace("(", "").replace(")", "").replace("(", "").replace(")", "")
replName = replName.replace("《", "").replace("》", "").replace("<", "").replace(">", "")
replName = replName.replace("〔", "").replace("〕", "")
replName = replName.replace("][", "-")
replName = replName.replace("[", "-").replace("]", "-")
replName = replName.replace("“", "").replace("”", "")
replName = replName.replace("\"", "")
replName = replName.replace("、", "").replace("!", "").replace("!", "")
replName = replName.replace(":", "").replace(";", "")
replName = replName.replace(". ", " ")
replName = replName.replace(" - ", "-").replace("-", "-")
replName = replName.replace(", ", " ").replace(",", "").replace(".", "")
replName = replName.replace("'", "").replace("’", "").replace("‘", "")
# for specific article abbrevations.
replNameSuffix, replNamePrefix = replName[-7:], replName[:-7]
replNamePrefix = replNamePrefix.replace(".-", "-").replace(".", " ")
replName = replNamePrefix + replNameSuffix
# special rule
replName = replName.replace("ieeetrans", "ieee trans").replace("smartgrid", "smart grid").replace("powersyst", "power syst")
isSame = origName == replName
if not isSame:
print(fileName)
os.rename(origName, replName)
# ans = input("lower this file and remove _? Y/N \n")
# if ans == "Y":
# os.rename(origName, replName)
else:
pass