Help me escape special characters used in a %VAR% variable
Posted: 03 Dec 2011 06:13
These fail to work for me :-
Is there any alternative to
NB The above is used in conjunction with
My problem is that I am starting with proven code with many instances such as
Adding an extra ^ before each existing ^ needs attention to detail,
and there may be other special characters that could trip me up.
I was hoping that two sets of double quotes around ""COMMAND=('findstr /n "^" %2')"" might fix the problem - but it fails me.
I need to add a large block of code to convert each processed file into an indexed array of text
and then perform some additional processing.
I intend to have just one screen full of code executed in
:NEW_PROC
rather than several dozen instances inserted into each portion of my present "in-line" code.
Regards
Alan
Code: Select all
SET "COMMAND=('findstr /n "^" %2')" & CALL :NEW_PROC %1 & GOTO :EOF
SET ""COMMAND=('findstr /n "^" %2')"" & CALL :NEW_PROC %1 & GOTO :EOF
Is there any alternative to
Code: Select all
SET "COMMAND=('findstr /n "^^" %2')" & CALL :NEW_PROC %1 & GOTO :EOF
NB The above is used in conjunction with
Code: Select all
:NEW_PROC
<%1 (
for /f %%i in %COMMAND% do (
set "ln=" & set /p "ln=" & echo(!ln!
)
)
GOTO :EOF
My problem is that I am starting with proven code with many instances such as
Code: Select all
:_D
<%1 (
for /f %%i in ('findstr /n "^" %2') do (
set "ln=" & set /p "ln=" & echo(!ln!
)
)
GOTO :EOF
:_P
<%1 (
for /f %%i in ('findstr /n /v "^" ^< %2') do (
set "ln=" & set /p "ln=" & echo(!ln!
)
)
GOTO :EOF
Adding an extra ^ before each existing ^ needs attention to detail,
and there may be other special characters that could trip me up.
I was hoping that two sets of double quotes around ""COMMAND=('findstr /n "^" %2')"" might fix the problem - but it fails me.
I need to add a large block of code to convert each processed file into an indexed array of text
and then perform some additional processing.
I intend to have just one screen full of code executed in
:NEW_PROC
rather than several dozen instances inserted into each portion of my present "in-line" code.
Regards
Alan