Click here for important information about Computing.net.

how to replace a text in dart file using batch script

January 19, 2021 at 05:56:02
Specs: Windows 10
How to replace a text in dart file using batch file
contain text as :
axis
I want to change the text as:
series

See More: how to replace a text in dart file using batch script


#1
January 20, 2021 at 04:34:50
Does it as a solution or not?

Reply ↓  Report •

#2
January 21, 2021 at 11:50:10
You can save this file as Search_Replace.bat and call it from command prompt :
This batch use a vbscript to search and replace a string

@echo off
Title Search and Replace
Set "Tmpvbs=%temp%\Tmpvbs.vbs"
set "String2Find=series"
set "ReplaceWith=axis"
REM %~dp0Test.txt is the path of inputfile with same batch file
Set "InputFile=%~dp0Test.txt"
REM with for loop we extract the name of the inputfile and we add the string New
@for %%f in ("%InputFile%") do Set "OutPutFile=%%~dpf%%~nf_New%%~xf"
REM Here we call our function in vbscript to search and replace
Call :Replace %String2Find% %ReplaceWith% "%InputFile%" "%OutPutFile%"
REM We delete our vbscript after using it
If Exist "%Tmpvbs%" Del "%Tmpvbs%"
pause & exit
::*************************************************************
:Replace <String2Find> <ReplaceWith> <InputFile> <OutPutFile>
Cls & echo(
echo Searching "%~1" into file "%~3" to Replace with "%~2"
(
echo Data = WScript.StdIn.ReadAll
echo Data = Replace(Data,"%~1","%~2",1, -1, 1^)
echo WScript.StdOut.WriteLine Data
)>"%Tmpvbs%"
cscript //nologo "%Tmpvbs%" < "%~3" > "%~4"
REM "%~1" is the first argument = String2Find
REM "%~2" is the second argument = ReplaceWith
REM "%~3" is the third argument = InputFile
REM "%~4" is the fourth agrument = Outputfile
REM we move our data to the original file inputfile after replacing it
Move /Y "%~4" "%~3">nul
Timeout /T 1 /nobreak>nul
exit /b
::*************************************************************


Reply ↓  Report •
Related Solutions


Ask Question