script-being-invoked.cmd:
REM This is my script file, it is being invoked from anywhere
REM Get absolute path to root directory
set astr=%~dp0
set substr1=\mq_1.7.6\interface\
set substr2=\
call set rootPath=%%astr:%substr1%=%substr2%%%
I'm trying to get the absolute directory path a few paths below from the file being invoked in the interface directory. The issue however is that the path in the code above changes. The version in mq_1.7.6 could change. Is there anyway to get this value via cmd scripting? I would have done \..\.. but this doesn't seem to work in Windows.
for %%I in ("%~dp0..\..") do set "rootPath=%%~fI"if the batch file is stored in directoryC:\Temp\Test & Debug\mq_1.7.6\interfaceand you want directory pathC:\Temp\Test & Debug.