It can't be checked just by comparing these variables:
C:\>set "d1=C:\"
C:\>set "d2=C:\Windows\.."
C:\>if %d1%==%d2% (echo true) else (echo false)
false
I can make up a sophisticated construct with pushd
and popd
and additional variables but isn't there a simpler way?
Similar to jeb's solution, but using FOR instead of called subroutine
for %%A in ("%d1%") do for %%B in ("%d2%") do if "%%~fA"=="%%~fB" (echo true) else (echo false)
You could normalize the variables with a small function.
set d1=C:\
set d2=C:\Windows\..
call :normalize d1
call :normalize d2
if "%d1%"=="%d2%" (echo true) else (echo false)
exit /b
:normalize
setlocal EnableDelayedExpansion
for /F "delims=" %%M in ("!%1!") do (
endlocal
set "%1=%%~dpM"
)
exit /b
dont know if it will suite to your need but you could create a file on 1st dir anc check if it exists in second :
echo test > %d1%\checkthisfile.txt
if exist %d2%\checkthisfile.txt (echo true)