Find knowledge base article(s) by searching for keywords in the title e.g. type linux in the search box below
Find knowledge base article(s) by browsing the subject categories of articles
Technology quick references, cheatsheets, user manuals etc.
Shop Online through ShopifyLite
Tutorials on various IT applications.
Search Title    (UL:0 |SS:f)

Software >> OS >> Windows >> Command Line >> Batch >> How to obtain the file name, extention, drive letter, path and fullpath of the running script

 

SPECIAL VARIABLES

Variable Purpose

%0

The script filename as it was called.
E.g. if we ran script.bat as script.  If we ran it as script.bat, it will return script.bat
 
%~d0 The drive letter of the running script
%~p0 The path part of the running script
%~n0 The file name part of the running script
%~e0 The file extention part of the running script
%~f0 The full path of the running script

 

EXAMPLE SCRIPT

d:\home\bin\script.bat

@echo off
echo.
echo This running script information :-
echo.
echo drive     %~d0
echo path      %~p0
echo filename  %~n0
echo extension %~x0
echo fullpath  %~f0

 

EXAMPLE OUTPUT

 

 

 

[ © 2008-2021 myfaqbase.com - A property of WPDC Consulting ]