import os
import sys
# 찾을 문자열
search_text = 'AddGridColumn("PRODUCTSPECNAME'
root_dir = "./"
# 현재 디렉토리에서 모든 폴더 탐색
for root, dirs, files in os.walk(root_dir,topdown=False):
# 모든 파일 탐색
for file in files:
# 파일 열기
if file == 'python.py':
continue
elif not file.endswith('.cs'):
continue
elif file.endswith('Designer.cs'):
continue
with open(os.path.join(root, file), "r",encoding='UTF-8') as f:
# 파일의 내용을 한줄씩읽기
content = f.readlines()
# contents 초기화
contents =""
is_search_text = False
for x in content:
# 찾을 문자열이 있는지 확인
contents= contents + x
if search_text in x:
target = x
target = target.replace("PRODUCTSPECNAME","PRODUCTSPECVERSION")
target = target.replace('LanguageService.Instance.GetLabel("ProductSpecName")','LanguageService.Instance.GetLabel("ProductSpecVersion")')
target = target.replace('LanguageService.Instance.GetLabel("PartName")','LanguageService.Instance.GetLabel("ProductSpecVersion")')
target = target.replace('LanguageService.Instance.GetLabel("Product")','LanguageService.Instance.GetLabel("ProductSpecVersion")')
contents = contents + target
is_search_text = True
# 파일에 내용을 쓰기
if is_search_text == True :
with open(os.path.join(root, file), "w",encoding='UTF-8') as f:
f.write(contents)
with open(os.path.join(root_dir, 'modify.txt'), "a",encoding='UTF-8') as f:
f.write(os.path.join(root, file)+'\n')
'dev > 기타' 카테고리의 다른 글
git 예쁘게 log 보기 by chatGPT (0) | 2025.01.20 |
---|---|
python - 폴더 내부의 파일 utf-8로 인코딩 변경 코드 (0) | 2023.08.22 |
이클립스 folding plugin coffee-bytes (0) | 2023.07.16 |
구글 검색 팁 (0) | 2022.07.07 |
협업프로그램 정리 ( 잔디 ) (0) | 2022.01.18 |
import os
import sys
# 찾을 문자열
search_text = 'AddGridColumn("PRODUCTSPECNAME'
root_dir = "./"
# 현재 디렉토리에서 모든 폴더 탐색
for root, dirs, files in os.walk(root_dir,topdown=False):
# 모든 파일 탐색
for file in files:
# 파일 열기
if file == 'python.py':
continue
elif not file.endswith('.cs'):
continue
elif file.endswith('Designer.cs'):
continue
with open(os.path.join(root, file), "r",encoding='UTF-8') as f:
# 파일의 내용을 한줄씩읽기
content = f.readlines()
# contents 초기화
contents =""
is_search_text = False
for x in content:
# 찾을 문자열이 있는지 확인
contents= contents + x
if search_text in x:
target = x
target = target.replace("PRODUCTSPECNAME","PRODUCTSPECVERSION")
target = target.replace('LanguageService.Instance.GetLabel("ProductSpecName")','LanguageService.Instance.GetLabel("ProductSpecVersion")')
target = target.replace('LanguageService.Instance.GetLabel("PartName")','LanguageService.Instance.GetLabel("ProductSpecVersion")')
target = target.replace('LanguageService.Instance.GetLabel("Product")','LanguageService.Instance.GetLabel("ProductSpecVersion")')
contents = contents + target
is_search_text = True
# 파일에 내용을 쓰기
if is_search_text == True :
with open(os.path.join(root, file), "w",encoding='UTF-8') as f:
f.write(contents)
with open(os.path.join(root_dir, 'modify.txt'), "a",encoding='UTF-8') as f:
f.write(os.path.join(root, file)+'\n')
'dev > 기타' 카테고리의 다른 글
git 예쁘게 log 보기 by chatGPT (0) | 2025.01.20 |
---|---|
python - 폴더 내부의 파일 utf-8로 인코딩 변경 코드 (0) | 2023.08.22 |
이클립스 folding plugin coffee-bytes (0) | 2023.07.16 |
구글 검색 팁 (0) | 2022.07.07 |
협업프로그램 정리 ( 잔디 ) (0) | 2022.01.18 |