Basch script howt to access the path 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 # | OUTPUT EXAMPLE
REM # | [current working directory] : %cd% : G:\DynamicWorkingDirectory
REM # | [batch folder path] : %~dp0 : G:\Deletable\
REM # | [batch files fullpath] : %~dpnx0 : G:\Deletable\01_Basic.bat
REM # | [batch files fullpath] : %~f0 : G:\Deletable\01_Basic.bat
Example 2: batch file path
@echo off
setlocal
set file=C:\Users\l72rugschiri\Desktop\fs.cfg
for %%i IN ("%file%") DO (
echo filedrive=%%~di
echo filepath=%%~pi
echo filename=%%~ni
echo fileextension=%%~xi
)