[batch] %~dp0 -- must remove \

December 27, 2010 at 11:06:31
Specs: Windows 7
set appdir=%~dp0
echo %~dp0 gives c:\test1\

what i want is:
echo %appdir% gives c:\test

need to remove \

how?
thanks!

.


See More: [batch] %~dp0 -- must remove \

Report •


#1
December 27, 2010 at 11:30:27
@echo off & setLocal EnableDELAYedeXpansion

echo %~DP0
set P=%~DP0
set P=!P:~0,-1!
echo.!P!


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
December 27, 2010 at 11:50:25
thanks but they got me wondering

what's the difference between:
echo.!P!
echo %p%

which gives the same output?

.


Report •

#3
December 27, 2010 at 11:56:15
The !P! form is needed within FOR and other structures. I usually use it by habit. In this case either will do.


=====================================
Life is too important to be taken seriously.

M2


Report •

Related Solutions


Ask Question