Page 1 of 1

variable dos ~dp0

Posted: 20 Sep 2012 07:39
by zizou
hello
i have ascript with this
SET SUBDIR=%~dp0
SET DRIVE=%cd:~0,3%

can anyone tell me the signification of the values assigned to the variable...thanks in advance

Re: variable dos ~dp0

Posted: 20 Sep 2012 08:05
by foxidrive
if the batch file is located at c:\files\batch\myfile.bat

then this will set subdir to c:\files\batch\
SET SUBDIR=%~dp0

This will take what is printed when you type ECHO %CD%
and will set DRIVE to the first three characters. (skip 0, take 3)

SET DRIVE=%cd:~0,3%


Try this:

@echo off
echo SET SUBDIR=%~dp0
echo SET DRIVE=%cd:~0,3%
pause