I'm trying to simply get the filenames from a directory into a loop and then process (with the eventual aim of then doing a substring on the filename), but can't get it to work.
I've googled plenty and it seems to me that what I'm doing should work, but I'm obviously missing something.
Here's my code:-
setlocal ENABLEDELAYEDEXPANSION
set files=*.*
FOR %%A IN ("%files%") DO (
echo %%A
Set MYVAR=%%A
echo MYVAR=%MYVAR%
)
pause
The echo of the %%A works fine, but MYVAR is always empty. I had this working
on 1 line earlier, before I added the brackets.
Please help. I've spent far too long on this already and am pulling my hair out.