Wednesday 15 April 2015

batch file - Programatically remove just the final slash from the path returned by "%~dp0" -



batch file - Programatically remove just the final slash from the path returned by "%~dp0" -

in cmd .bat file, how may programatically remove final slash path returned "%~dp0"?

this solve failure of command

subst f: "%~dp0"

giving

s:\tlib distribution\fg trial>subst f: "s:\tlib distribution\fg trial\" path not found - s:\tlib distribution\fg trial\

whereas

s:\tlib distribution\fg trial>subst f: "s:\tlib distribution\fg trial" s:\tlib distribution\fg trial>

succeeds.

option 1:

pushd "%~dp0" subst f: . popd

option 2:

for %%a in ("%~dp0\.") subst f: "%~fa"

option 3:

for %%a in ("%~f0\..") subst f: "%~fa"

batch-file windows-7 cmd

No comments:

Post a Comment