Repository navigation
Expand file tree
/
Copy pathreplaceFileContent.py
More file actions
50 lines (39 loc) · 1.61 KB
/
Copy pathreplaceFileContent.py
File metadata and controls
50 lines (39 loc) · 1.61 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
import os
def replaceFileContent(path):
for file in os.listdir(path):
if os.path.isdir(path + '/' + file):
replaceFileContent(path + '/' + file)
# print('==========')
else:
# print(file)
if file == '.DS_Store':
continue
newContent = ''
# with open(path + '/' + file, "r+", encoding='utf-8') as f:
#
# content = f.read()
#
# if 'ViewModel' in content:
# newContent = content.replace("ViewModel", "ViewModel_NEW")
#
# else:
# newContent = content
#
# if 'ViewController' in newContent:
# newContent = newContent.replace("ViewController", "ViewController_NEW")
#
# with open(path+'/'+file, 'w', encoding='utf-8') as f:
# f.write(newContent)
# if 'ViewModel' in file:
# newName = file.replace("ViewModel", "ViewModel_NEW")
# os.rename(os.path.join(path,file), os.path.join(path,newName))
#
#
# if 'ViewController' in file:
# newName = file.replace("ViewController", "ViewController_NEW")
# os.rename(os.path.join(path,file), os.path.join(path,newName))
if ".h" in file:
vc = file.replace("ViewModel", "ViewController")
print("@\"%s\" : @\"%s\"," %(file[0:-2], vc[0:-2]))
if __name__ == '__main__':
replaceFileContent('/Users/lynn/Desktop/公文审批(新)')