-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a py file search and replace string bat script
- Loading branch information
1 parent
02f1db1
commit e5db881
Showing
4 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
175 changes: 175 additions & 0 deletions
175
10_Double_Click_Me_To_Search_Replace_a_string_in_a_Py_file.bat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
|
||
|
||
@echo off | ||
REM this is getting the path where the bat file is. | ||
cd /D "%~dp0" | ||
setlocal enabledelayedexpansion | ||
|
||
@REM set "search_sentence=This is the old sentence." | ||
@REM set "replace_sentence=This is the new sentence." | ||
|
||
set search_sentence=Is_development:bool=True | ||
set replace_sentence=Is_development:bool=False | ||
@REM set file_path=%CD%\10_Double_Click_Me_To_Search_Replace_a_string_in_a_Py_file_example.py | ||
@REM set temp_file=temp.py | ||
|
||
set "file_path=%CD%\10_Double_Click_Me_To_Search_Replace_a_string_in_a_Py_file_example.py" | ||
set "temp_file=temp.py" | ||
|
||
(for /f "tokens=*" %%a in ('type "%file_path%"') do ( | ||
set "line=%%a" | ||
set "trimmed_line=!line: =!" | ||
set "trimmed_search=!search_sentence: =!" | ||
if "!trimmed_line!"=="!trimmed_search!" ( | ||
echo %replace_sentence% | ||
) else ( | ||
echo !line! | ||
) | ||
)) > "%temp_file%" | ||
|
||
move /y "%temp_file%" "%file_path%" | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
@REM @echo off | ||
@REM setlocal enabledelayedexpansion | ||
|
||
@REM REM this is getting the path where the bat file is. | ||
@REM cd /D "%~dp0" | ||
@REM set search_sentence=Is_development:bool=True | ||
@REM set replace_sentence=Is_development:bool=False | ||
|
||
@REM set file_path=%CD%\10_Double_Click_Me_To_Search_Replace_a_string_in_a_Py_file_example.py | ||
@REM set temp_file=temp.py | ||
|
||
@REM (for /f "tokens=*" %%a in ('type "%file_path%"') do ( | ||
@REM set "line=%%a" | ||
@REM set "trimmed_line=!line: =!" | ||
@REM set "trimmed_search=!search_sentence: =!" | ||
@REM set "output_line=" | ||
|
||
@REM :replace_loop | ||
@REM if "!line: %search_sentence%=!" neq "!line!" ( | ||
@REM set "line=!line:%search_sentence%=%replace_sentence%!" | ||
@REM set "output_line=!output_line!!replace_sentence!" | ||
@REM goto replace_loop | ||
@REM ) | ||
|
||
@REM if defined output_line ( | ||
@REM echo !output_line! | ||
@REM ) else ( | ||
@REM echo !line! | ||
@REM ) | ||
@REM )) > "%temp_file%" | ||
|
||
@REM move /y "%temp_file%" "%file_path%" | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
@REM @echo off | ||
@REM setlocal enabledelayedexpansion | ||
|
||
@REM set search_sentence=Is_development:bool=True | ||
@REM set replace_sentence=Is_development:bool=False | ||
|
||
@REM set file_path=%CD%\10_Double_Click_Me_To_Search_Replace_a_string_in_a_Py_file_example.py | ||
@REM set temp_file=temp.py | ||
|
||
@REM (for /f "tokens=*" %%a in ('type "%file_path%"') do ( | ||
@REM set "line=%%a" | ||
@REM set "trimmed_line=!line: =!" | ||
@REM set "trimmed_search=!search_sentence: =!" | ||
@REM if "!trimmed_line!"=="!trimmed_search!" ( | ||
@REM echo %replace_sentence% | ||
@REM ) else ( | ||
@REM echo !line! | ||
@REM ) | ||
@REM )) > "%temp_file%" | ||
|
||
@REM move /y "%temp_file%" "%file_path%" | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
@REM @echo off | ||
@REM setlocal enabledelayedexpansion | ||
|
||
@REM REM this is getting the path where the bat file is. | ||
@REM cd /D "%~dp0" | ||
|
||
@REM set search_sentence=Is_development:bool=True | ||
@REM set replace_sentence=Is_development:bool=False | ||
|
||
@REM set file_path=%CD%\10_Double_Click_Me_To_Search_Replace_a_string_in_a_Py_file_example.py | ||
@REM set temp_file=temp.py | ||
|
||
@REM (for /f "tokens=*" %%a in ('type "%file_path%"') do ( | ||
@REM set "line=%%a" | ||
@REM if "!line!"=="%search_sentence%" ( | ||
@REM echo %replace_sentence% | ||
@REM ) else ( | ||
@REM echo !line! | ||
@REM ) | ||
@REM )) > "%temp_file%" | ||
|
||
@REM move /y "%temp_file%" "%file_path%" | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
@REM @echo off | ||
@REM @echo off | ||
@REM setlocal enabledelayedexpansion | ||
@REM REM this is getting the path where the bat file is. | ||
@REM cd /D "%~dp0" | ||
|
||
@REM set search_text=Is_development:bool=True | ||
@REM set replace_text=Is_development:bool=False | ||
|
||
@REM set path=%CD% | ||
@REM set file_path=%CD%\10_Double_Click_Me_To_Search_Replace_a_string_in_a_Py_file_example.py | ||
@REM set "temp_file=temp.py" | ||
|
||
@REM (for /f "tokens=*" %%a in ('type "%file_path%"') do ( | ||
@REM set "line=%%a" | ||
@REM set "line=!line:%search_text%=%replace_text%!" | ||
@REM echo !line! | ||
@REM )) > "%temp_file%" | ||
|
||
@REM move /y "%temp_file%" "%file_path%" |
8 changes: 8 additions & 0 deletions
8
10_Double_Click_Me_To_Search_Replace_a_string_in_a_Py_file_example.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Is_development:bool=True | ||
Is_development:bool=True | ||
Is_development:bool=True | ||
Is_development:bool=True | ||
Is_development:bool=True | ||
Is_development:bool=True | ||
Is_development:bool=True Is_development:bool=True Is_development:bool=True | ||
Is_development:bool=True |
File renamed without changes.
16 changes: 16 additions & 0 deletions
16
testing/10_Double_Click_Me_To_Search_Replace_a_string_in_a_Py_file_example.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import bpy | ||
|
||
|
||
|
||
|
||
|
||
Is_development:bool=True | ||
|
||
|
||
Is_development:bool=True | ||
|
||
|
||
Is_development:bool=True | ||
|
||
|
||
Is_development:bool=True Is_development:bool=True Is_development:bool=True |