use for loop to set local variable
Posted: 16 Dec 2019 05:18
Hi
Within my .bat file I want to get the name of the only file in a folder (I am guaranteed that there will only ever be 1 file)
I have tried this
but fn is not set as expected
First question: why not and how can I fix
Second question : this seems a clunky solution - is there a better way
Within my .bat file I want to get the name of the only file in a folder (I am guaranteed that there will only ever be 1 file)
I have tried this
Code: Select all
set fn="a"
for /r %%i in (*) do set %fn% = %%~nxi
First question: why not and how can I fix
Second question : this seems a clunky solution - is there a better way