:: PATHEDIT.BTM
setlocal
if "%1" == "/?" goto syntax
if "%1" == "/A" (shift & goto append)
if "%1" == "/P" (shift & goto prepend)
set before=%temp\pathedit_before.tmp
set after=%temp\pathedit_after.tmp
path /n > %before
start /wait /pgm "%@path[%_cmdspec]\tcedit.exe" %before
:: below, the second replace gets rid of a
:: trailing ';' which could be just left there
tpipe ^
/input=%before ^
/output=%after ^
/replace=0,0,0,0,0,0,0,0,0,\r\n,; ^
/replace=4,0,0,0,0,0,0,0,0,";\Z",""
set path=%@line[%after,0]
goto done
:append
:: don't add a second ';' (not really necessary)
set semicolon=%@if["%@right[1,%path]" == ";",,;]
set path=%[path]%[semicolon]%1$
goto done
:prepend
set path=%1$;%path
goto done
:syntax
echo Usage: PATHEDIT.BTM [[/A(ppend) ^| /P(repend)] string]^r^n
echo ^tWithout /A or /P, interactive using TCEDIT.EXE
echo ^tDo not quote string
echo ^tString can be of the form dir1;dir2[...]
goto done
:done
endlocal path