For each folder, ..
points to its parent folder, so, two levels up from current folder is ..\..
. Now, to convert the relative reference to a absolute full path, we need to get a reference to the pointed file/folder. To do it we can pass the relative reference as an argument to a subroutine or we can use a for
command
@echo off
setlocal enableextensions disabledelayedexpansion
set "newDir=..\..\bin"
rem With a subroutine
call :resolve "%newDir%" resolvedDir
echo %resolvedDir%
rem With a for - retrieve the full path of the file/folder being
rem referenced by the for replaceable parameter
for %%f in ("%newDir%") do echo %%~ff
endlocal
goto :EOF
:resolve file/folder returnVarName
rem Set the second argument (variable name)
rem to the full path to the first argument (file/folder)
set "%~2=%~f1"
goto :EOF
EDIT
The submitted code gets relative path for the current directory, not batch file directory. If batch file relative is what you need, try
set "newDir=%~dp0\..\..\bin\"
where %~dp0
is the drive and path of the current batch file (%0
is a reference to the current batch file) and proced with the same/similar code