I use %0
in batch file to get the containing directory of the batch file but the result is :-
c:\folder1\folder2\batch.bat
I want just directory, without batch file name, like this :-
c:\folder1\folder2\
How can I do it? Maybe I should filter the path. If yes, how can I do it?
Will return the path only.
Will return the drive+path.
More info on the subject can be found on Microsoft's site.
Information about this syntax can also be found in the help for the for command by executing
for /?
on a Windows OS.The current directory is held in %CD%
Some expressions that effect the filename:
~f0
will give the fully qualified file name.~dpnx0
will give the same as~f0
, but this shows you that you can break it down into parts: d=drive p=path n=name x=extensionuse chdir command
Option 1:
Option 2: