I am writing simple script to check if somefolder exists in available drives. however %%G always shows empty string when concat with ":\somefolder" if I just echo %%G it shows all the available drives. I am new to batch scripting , not sure what am I missing here.
Thanks in advance.
@echo off
::parse the VER command
FOR /F "tokens=*" %%G IN ('wmic logicaldisk get caption') DO (
IF [%%G]==[] (
echo "empty string"
) ELSE (
SET var="%%G\somefolderpath"
IF EXIST %var% (
echo %var% found
) ELSE (
echo %var% not found
)
)
)