usage of Find/Replace utility (BatchSubstitute.bat) its code is :
@echo off
REM -- Prepare the Command Processor --
SETLOCAL ENABLEEXTENSIONS
SETLOCAL DISABLEDELAYEDEXPANSION
::BatchSubstitude - parses a File line by line and replaces a substring"
::syntax: BatchSubstitude.bat OldStr NewStr File
:: OldStr [in] - string to be replaced
:: NewStr [in] - string to replace with
:: File [in] - file to be parsed
if "%*"=="" findstr "^::" "%~f0"&GOTO:EOF
for /f "tokens=1,* delims=]" %%A in ('"type %3|find /n /v """') do (
set "line=%%B"
if defined line (
call set "line=echo.%%line:%~1=%~2%%"
for /f "delims=" %%X in ('"echo."%%line%%""') do %%~X
) ELSE echo.
)
Length of record in my input file is 2600 bytes. but the above utility is only reading 1032 bytes of record and ignoring the rest. Kindly suggest how can i make it to read whole 2600 length record for find and replace.
please help...
thank you
usage of Find/Replace utility (BatchSubstitute.bat)
Moderator: DosItHelp
-
- Posts: 2
- Joined: 10 May 2009 02:18
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Well, the "find" command is the culprit. Use findstr instead like this:
Code: Select all
for /f "usebackq tokens=1,* delims=:" %%A in (`type %3^|findstr /n ".*"`) do (
-
- Posts: 2
- Joined: 10 May 2009 02:18
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Hmm. Both find and findstr appear to be limited in their ability to parse. You can just do this (untested):
for /f "usebackq delims=" %%A in ("%~3") do (
set "line=%%A"
call echo %%line:%~1=%~2%%
)
But blank lines will be skipped. You could get creative and use the find /n /v command to figure out which line numbers are blank in one for loop, and then use a simple counter in a 2nd for loop like I have above to trigger when you should output a blank echo. Here's what I mean:
That will probably work for you. Might choke on special characters, though.
Ted
for /f "usebackq delims=" %%A in ("%~3") do (
set "line=%%A"
call echo %%line:%~1=%~2%%
)
But blank lines will be skipped. You could get creative and use the find /n /v command to figure out which line numbers are blank in one for loop, and then use a simple counter in a 2nd for loop like I have above to trigger when you should output a blank echo. Here's what I mean:
Code: Select all
@echo off
setlocal enabledelayedexpansion
set idx=0
for /f "usebackq tokens=1,2 delims=[]" %%a in (`type "%~3" ^| find /n /v ""`) do (
set tmp=%%b
if not defined tmp (
set /a idx+=1
set "blankline!idx!=%%a"
)
)
set idx=1
set count=1
for /f "usebackq delims=" %%A in ("%~3") do (
call set "nextblankline=blankline!idx!"
call set "nextblankline=%%!nextblankline!%%"
if 1!nextblankline!==1!count! (
set /a count+=1
set /a idx+=1
echo.
)
set "line=%%A"
call echo.%%line:%~1=%~2%%
set /a count+=1
)
That will probably work for you. Might choke on special characters, though.
Ted