Reputation: 764
I have a variable
set i = %1
%1 is d:\work\temp_h.txt
I want to get a path "d:\work". If I use the below code I can get the name of path
%%~nxi
%%~nxi= temp_h.txt. How can I get the path of i ? ( like that d:\work )
Upvotes: 1
Views: 92
Reputation: 3641
%~I expands %I removing any surrounding quotes (")
%~fI expands %I to a fully qualified path name
%~dI expands %I to a drive letter only
%~pI expands %I to a path only
%~nI expands %I to a file name only
%~xI expands %I to a file extension only
%~sI expanded path contains short names only
%~aI expands %I to file attributes of file
%~tI expands %I to date/time of file
These are some of the modifiers that can be used. In your case you can use %~dp1
Upvotes: 1
Reputation: 14039
set subdir=%~dp1
echo %subdir%
This will give you the directory part of whatever is there in %1
- first command line argument.
Upvotes: 1