批处理参数:%1之后的所有内容 [英] batch parameters: everything after %1
问题描述
重复:
- Is there a way to indicate the last n parameters in a batch file?
- how to get batch file parameters from Nth position on?
说明:我知道循环方法-即使在命令扩展之前也可以使用;我希望找到一些有趣且未记录的东西,例如%〜* 1或其他任何东西-就像在
Clarification: I knew of the looping approach - this worked even before Command Extensions; I was hoping for something fun and undocumented like %~*1 or whatever - just like those documented at http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/percent.mspx?mfr=true.
在Windows批处理文件(启用了命令扩展")中,%1是第一个参数,%2是第二个参数,依此类推.%*是所有已连接的参数.
In a Windows batch file (with the so called "Command Extensions" on), %1 is the first argument, %2 is the second, etc. %* is all arguments concatenated.
我的问题:例如,有没有办法在%2之后获得所有东西?
My question: is there a way to get everything AFTER %2, for example?
我找不到这样的东西,它将对我正在研究的东西有所帮助.
I couldn't find such a thing, and it would be helpful for something I'm working on.
推荐答案
我不确定是否有直接命令,但是您始终可以使用简单的循环和平移来获取变量中的结果.像这样:
I am not sure if there is a direct command but you can always use a simple loop and shift to get the result in a variable. Something like:
@echo off
set RESTVAR=
shift
:loop1
if "%1"=="" goto after_loop
set RESTVAR=%RESTVAR% %1
shift
goto loop1
:after_loop
echo %RESTVAR%
让我知道是否有帮助!
这篇关于批处理参数:%1之后的所有内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!