batch file - What does %~dp0 mean, and how does it work? -


i find %~dp0 useful, , use lot make batch files more portable.

but label seems cryptic me... ~ doing? dp mean drive , path? 0 refer %0, path batch file includes file name?

or weird label?

i'd know if documented feature, or prone deprecated.

calling

for /? 

in command-line gives syntax (which can used outside for, too, place can found).

in addition, substitution of variable references has been enhanced. can use following optional syntax:

%~i         - expands %i removing surrounding quotes (") %~fi        - expands %i qualified path name %~di        - expands %i drive letter %~pi        - expands %i path %~ni        - expands %i file name %~xi        - expands %i file extension %~si        - expanded path contains short names %~ai        - expands %i file attributes of file %~ti        - expands %i date/time of file %~zi        - expands %i size of file %~$path:i   - searches directories listed in path                environment variable , expands %i                qualified name of first 1 found.                if environment variable name not                defined or file not found                search, modifier expands                empty string 

the modifiers can combined compound results:

%~dpi       - expands %i drive letter , path %~nxi       - expands %i file name , extension %~fsi       - expands %i full path name short names %~dp$path:i - searches directories listed in path                environment variable %i , expands                drive letter , path of first 1 found. %~ftzai     - expands %i dir output line 

in above examples %i , path can replaced other valid values. %~ syntax terminated valid variable name. picking upper case variable names %i makes more readable , avoids confusion modifiers, not case sensitive.

there different letters can use f "full path name", d drive letter, p path, , can combined. %~ beginning each of sequences , number i denotes works on parameter %i (where %0 complete name of batch file, assumed).


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -