So I am looping through files within a directory and want to get the filename and as i get the filename I will want to break it down with delim because I will be getting the first portion of the name before the first underscore. Many examples use this for /f loo[ with token/delim settings but when i run this code it says for the echo of i as: !var! and then when I get ride of the "" i get The system cannot find the file !var!
I am guessing my syntax is incorrect and maybe even my approach of my script is as well. Any suggestions?
@ECHO OFF
for /r %%a in (*.pdf) do (
echo %%~nxa
set var=%%~nxa
for /F "tokens=1-2 delims=_" %%i in ("!var!") do (
echo %%i %%j
)
)
PAUSE