bat中直接使用文件名,可用下面
set name=%~n0
用到了下面链接的第二个答案
https://zhidao.baidu.com/question/556178601.html
其中~n0的意思:
%0 批处理自己
%1 第1个参数
%2 第2个参数
依次到%9
对于变量%0~%9及for里使用的%i这样的变量,可以有以下的语法:
https://stackoverflow.com/questions/15567809/batch-extract-path-and-filename-from-a-variable
in HELP CALL
or HELP FOR
you may find more detailed information:
%~1 - expands %1 removing any surrounding quotes (")
%~f1 - expands %1 to a fully qualified path name
%~d1 - expands %1 to a drive