Page 1 of 1
Dir of .bat file in variable
Posted: 14 Jan 2009 08:21
by chill
hi how do I get the dir of the started .bat file in a varaible?
%0 saves the pfad + file name. thx
Posted: 16 Jan 2009 01:04
by DosItHelp
chill,
If for example your batch file is at
c:\dostips\chill\mybatch.cmd then:
set fullname=%~f0
set name=%~n0
set extension=%~x0
set drive=%~d0
set folder=%~p0
set driveAndFolder=%~dp0
will set the variables as follows:
fullname will be:
c:\dostips\chill\mybatch.cmd
name will be
mybatch
extension will be
.cmd
drive will be
c:
folder will be
\dostips\chill\
driveAndFolder will be
c:\dostips\chill\
DosItHelp?