In a batch file, you can use the %~dp0
special variable to get the directory of the currently executing batch file. Here's how you can do it:
@echo off
echo The directory of this batch file is: %~dp0
When you run this batch file, it will display the directory where the batch file is located.
Explanation:
%0
represents the name of the currently executing batch file.%~dp0
extracts the drive and path from%0
, which effectively gives you the directory of the batch file.
This is a common way to obtain the directory of the batch file within the batch script itself.
- directory current scripts batch filedirectory current scripts batch chromedriver directory current exist variables scripts reuse batch directory current modules parent batch-file directory go current modules commands script batch 926 scripts print empty batch directory the current python comments batch file 893