batch file get current directory code example
Example 1: batch directory
echo [current working directory] : %%cd%% : %cd%
echo [batch folder path] : %%~dp0 : %~dp0
echo [batch files fullpath] : %%~dpnx0 : %~dpnx0
echo [batch files fullpath] : %%~f0 : %~f0
REM
REM
REM
REM
REM
Example 2: get current directory batch
%cd% refers to the current working directory (variable)
%~dp0 refers to the full path to the batch file's directory (static)
%~dpnx0 and %~f0 both refer to the full path to the batch directory and file name (static).