%〜1在此批处理文件中做什么? [英] What does %~1 do in this batch file?
本文介绍了%〜1在此批处理文件中做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我找到了这段代码,但是有些部分我不理解.
I found this code, but there are parts that I do not understand.
这是我的代码:
Main.bat:
@echo off
set "CallCount=0"
set "Mood="
set /P "Mood=Your mood is: "
call Receive.bat "%Mood%"
rem *Random stuff*
set "Food="
set /P "Food=The food you want is: "
call Receive.bat "%Food%"
set "CallCount="
Receive.bat:
Receive.bat:
@echo off
set /A CallCount+=1
if "CallCount"=="2" goto Call2
if not "%~1"=="" echo %1 <----
*Random Stuff* |
goto :EOF |---What is %~1 doing in this area?
:Call2 |
if not "%~1"=="" echo %1 <----
rem Commands for second call.
这是一个使用call命令两次的文件.
This is a file that uses the call command twice.
推荐答案
%1
是调用命令行的第一个参数.如果传递的参数周围带有引号,则%1
包含引号.在%〜1
中,提供了带有引号的参数值.
%1
is the first argument form the invoking command line. If the passed argument has quotes around it, %1
includes the quotes. Where as, %~1
provides the argument value with quotes removed.
有用的参考资料此处.
这篇关于%〜1在此批处理文件中做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文