[902] Get the current file's directory of CMD batch scripts
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:
%0represents the name of the currently executing batch file.%~dp0extracts 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.
浙公网安备 33010602011771号