new to batch file scripting. Need your all help to extract all the values which are in (single quotes) '' from below text file (file.txt) and find that value in another text file, if not exists throw an error.
file.txt
Wed 11/01/2023 - 19:59:23.33
BIP1138I: Applying overrides using runtime mqsiapplybaroverrides...
BIP1140I: Overriding property FTP_To_Trg#FtpServer with 'ftp.test.com' in 'App_Common_APP/META/broker.xml' ...
BIP1140I: Overriding property FTP_To_Trg#FileOut with 'ftp.test.com' in 'App_Common_APP/META/broker.xml' ...
BIP1140I: Overriding property Email#UDP_SysNm with 'SIT' in 'App_Common_APP/META/broker.xml' ...
I have updated file paths and tried it didn't work, after running the script I don't see anything happening, providing file paths caused an issue?
@ECHO Off
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /f "delims=" %%e IN (C:\Users\k2\file.txt) DO FOR %%y IN (%%e) DO (
SET "word=%%y"
IF "!word:~0,1!!word:~-1!"=="''" (
FIND "!word:~1,-2!" C:\Users\k2\result.txt>nul
IF ERRORLEVEL 1 (>>C:\Users\k2 ECHO %%y) ELSE (>>C:\Users\k2 ECHO %%y)
)
)
Tried with file names and yet I don't see anything happening, I have also provided double quotes("") for filePaths, is that issue?
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /f "delims=" %%e IN ("C:\Users\k2\file.txt") DO FOR %%y IN (%%e) DO (
ECHO %%y
SET "word=%%y"
IF "!word:~0,1!!word:~-1!"=="''" (
ECHO processing %%y
FIND "!word:~1,-2!" "C:\Users\k2\result.txt">nul
IF ERRORLEVEL 1 (>>"C:\Users\k2\Failure.txt" ECHO %%y)
ELSE (>>"C:\Users\k2\Success.txt" ECHO %%y)
)
)
editbutton to edit it into your question. Highlight it and press{}to indented for display.