Given that the current directory, %CD%
is
C:\Parent\Child
In a batch file, how can I get the value Child
in to a variable?
thanks
Given that the current directory, %CD%
is
C:\Parent\Child
In a batch file, how can I get the value Child
in to a variable?
thanks
@manojlds's answer is not correct for all cases.
The
%%~nI
shortcut works fine for files, but not for directories.Example:
C:\a..o\ex.bat
If I execute this batch file from its location, the output is
"a."
:Solution:
A possible solution is the following:
C:\sol.bat
Tests:
Here is the answer
or you can do something like this
From here: https://superuser.com/questions/160702/get-current-folder-name-by-a-dos-command