In windows batch file, having a variable %location%
where is stored a full path (eg: e:\root_dir\sub1\sub2
), how can one extract the full path excluding the drive letter? Result should be stored in a variable and for previous example result would be be\root_dir\sub1\sub2
Asked
Active
Viewed 31 times
0

codiac
- 1,857
- 4
- 18
- 31
1 Answers
0
This should do it:
FOR /F "usebackq tokens=* delims=" %%A IN ('%location%\') DO SET Result=%%~pA
Result of %location%
being e:\root_dir\sub1\sub2
would yield %Result%
= \root_dir\sub1\sub2\
.

Jason Faulkner
- 6,378
- 2
- 28
- 33