I have to store the ouput of DIR
in a variable.
This was asked before e.g. here or here or here.
They all provide an answer more or less similar to what I'm using right now:
%= Find the *.sln file and write its path to the file temp.temp =%
DIR /s/b *.sln > temp.temp
%= Read out the content of temp.temp again to a variable =%
SET /p texte=< temp.temp
%= Remove the temp.temp file =%
DEL temp.temp
%= Get only the filename without path =%
FOR %%A IN ("%texte%") DO (
SET Name=%%~nxA
)
But in my case I'm sure that the ouput of DIR /s/b *.sln
will allways be a one-liner. To me it looks a bit ugly to have to
a) store the ouput in an external file and
b) run a FOR
loop over it though I already know it will only have one line.
Is there any direct/simpler way to do this?