@ECHO OFF
SET filename=autoexec.bat
FOR /R C:\ %%a IN (\) DO (
IF EXIST "%%a\%filename%" (
SET fullpath=%%a%filename%
GOTO break
)
)
:break
ECHO %fullpath%
Will give me a path with \\
in between. How to come up with only \
in between?
It's because you are doing:
Try instead, replacing the
\
with*
;The value in the brackets is the file set that you want to loop through, an asterisk specifies ALL.