I have a text file and I\'m interested to have only a part of it, all that is included between wordA and wordB
Is that possible using a cmd batch file?
Here's one way to do it. Assuming that wordA and wordB are on the same line (both must be present). The subroutine :FindString removes undesired preceding text and then replaces "wordB" with a character that we don't expect in the text that we will then use as a delimiter (` in this case). use another character if necessary.
@ECHO OFF
SET InFile=Test.txt
FOR /F "tokens=*" %%A IN ('FINDSTR "wordA" "%InFile%" ^| FINDSTR "wordB"') DO CALL :FindString "%%A"
pause
GOTO :eof
:FindString
SET String=%~1
SET String=%String:*wordA =%
SET String=%String: wordB=`%
FOR /F "tokens=1 delims=`" %%A IN ('ECHO.%String%') DO ECHO.%%A]
GOTO :eof