variable dos ~dp0

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
zizou
Posts: 1
Joined: 20 Sep 2012 07:32

variable dos ~dp0

#1 Post by zizou » 20 Sep 2012 07:39

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

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: variable dos ~dp0

#2 Post by foxidrive » 20 Sep 2012 08:05

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

Post Reply