What your code does:
dir /b /s /a-d "%%a:\gm_construct.bsp" set p=%%~dpnxa
lists all files "%%a:\gm_construct.bsp"
and all files named set
and all files named p=%%~dpnxa
What (I think) you want to do:
dir /b /s /a-d "%%a:\gm_construct.bsp"
and set it's output to the variable %p%
To get a command's output, you need another for
:
for /f "delims=" %%i in ('dir /b /s /a-d "%%a:\gm_construct.bsp"') do set p=%%~dpnxi
integrated into your code (note the kind of the single quotes: '
):
@echo off
for %%a in (d) do (
if exist "%%a:\" (
for /f "delims=" %%i in ('dir /b /s /a-d "%%a:\gm_construct.bsp"') do set p=%%~dpnxi
)
)
pause
pause