Reprinted from: http://www.hackbase.com/tech/2009-08-12/54871.html
Summary of batch processing itself % 0.
During batch processing, you often need to perform operations on yourself,
For example, extract path, file name, suffix, size, and so on ....
The % 0 extension can be easily implemented.
: Code by @ bbs.bathome.cn 2008/01/08
1. Obtain the complete batch processing path
@ Echo off
Echo % 0
Pause
2. Obtain the complete batch processing path and remove the quotation marks at the beginning and end of the batch processing.
@ Echo off
Echo % ~ 0
Pause
3. Get the batch processing file name and suffix
@ Echo off
Echo % ~ Nx0
Pause
4. Get the batch processing file name
@ Echo off
Echo % ~ N0
Pause
5. Get the suffix of the batch processing.
@ Echo off
Echo % ~ X0
Pause
6. Obtain the complete path of the batch processing, excluding the file name
@ Echo off
Echo % ~ Dp0
Pause
Or
@ Echo off
Echo % Cd %
Pause
7. Obtain the drive letter of the batch processing.
@ Echo off
Echo % ~ D0
Pause
8. Obtain the batch size.
@ Echo off
Echo % ~ Z0
Pause
9. Obtain the modification time of the batch processing.
@ Echo off
Echo % ~ T0
Pause
@ Echo off
Echo current drive letter: % ~ D0
Echo current drive letter and Path: % ~ Dp0
Echo full path of current batch processing: % ~ F0
Echo short file name format of the current drive letter and Path: % ~ Sdp0
Echo current cmd default directory: % Cd %
Pause