Okay I am trying to check the variable that contains the string pg but it says yes for each file name. Eventually based on each file that my have g, pg, or neither I will do further things which I might have to create other questions for or maybe one cool btach scripter here can teach me if i get stuck:
@ECHO OFF
setlocal enabledelayedexpansion
set message=Hello World
echo %message%
echo -------------------
for /f "tokens=1-2 delims=_" %%i in ('dir /B /A-D "*.pdf"') do (
set var=%%i
echo !var!
set var2=pg
If NOT "%var%"=="%var:%var2%=%" (
echo Yes
) else (
echo No
)
)
PAUSE
Here is my output:
Hello World
-------------------
00000
Yes
00267
Yes
20859
Yes
G0454
Yes
P01339
Yes
PG0435
Yes
PG2522
Yes