Why doesn't this replacement work?
Posted: 11 Jul 2020 09:23
Hi Folks -
I have the following script (trimmed down for example purposes):
I'm obviously within a code block so I need to use !, but why won't the comma to space replacement work?
I can remove the commas, leave the spaces and use !SEARCH! and it works fine, but here is room for error with that approach.
Now I could just put the SEARCH variable outside the block, but I don't want to do that. ANy ideas?
I have the following script (trimmed down for example purposes):
Code: Select all
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET X=T
PUSHD "D:\TEMP"
IF DEFINED X (
SET "SEARCH="Rule Name","File Name:","Error: 3303","Error: 3304","Error: 3333","Error: 3335","Error: 3336","Error: 3337","does not exist for the specified cube or you do not have access to it""
SET "FDMEE_KOF=_KICKOUTS_.txt"
FOR %%A IN ( !SEARCH:,= ! ) DO (
FOR /F "tokens=* delims=" %%a IN ('FINDSTR /C:"%%~A","20200711_1055_FIN_IQ_2002.log"') DO (
ECHO %%a>>"!FDMEE_KOF!"
)
)
POPD & EXIT /B 1
)
CLS
GOTO :EOF
Code: Select all
( !SEARCH:,= ! ) DO (
Now I could just put the SEARCH variable outside the block, but I don't want to do that. ANy ideas?