Naive substrings have a problem that you have to tweak them every time your paths change, and this is not a general solution to the problem.
The following batch file provides proof of how you can do part of the path truncation:
@echo off set foo=C:\Temp\Test call :strip echo %foo% goto :eof :strip if not "%foo:~-1%"=="\" ( set foo=%foo:~0,-1% goto :strip ) goto :eof
It is hard-coded for one variable, but is easily fixed if necessary.
The main part here is the strip routine, which loops and truncates the last character of the string until a backslash is found. This effectively removes the last part of the path.
Joey
source share