windows - 批处理,调用 : Why can't I pass a token to my subroutine?

标签 windows batch-processing

这一定很简单。不幸的是,我也是。

“filelist.txt”是输出:dir/b

此代码有效:对于“filelist.txt”中的每一行,该行都按预期回显。

for /F "tokens=*" %%A in (filelist.txt) do echo %%A

此代码不起作用:对于“filelist.txt”中的每一行,仅回显变量名称“%A”。

for /F "tokens=*" %%A in (filelist.txt) do call :sub1
goto :eof
:sub1
echo %%A
goto :eof

我做错了什么?提前致谢。

最佳答案

尝试:

@echo off
for /F "tokens=*" %%A in (filelist.txt) do call :sub1 %%A
goto :eof
:sub1
echo %1
goto :eof

您需要将参数 (%%A) 传递给子例程 (arg guide),然后在您的子例程中您可以按位置访问它 (%1 ).

关于windows - 批处理,调用 : Why can't I pass a token to my subroutine?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4831629/

相关文章:

hadoop - 用于长时间运行和大型批处理的 Apache Ignite

windows - GtkGLExt+Haskell 程序在 Windows 上运行比在 Linux 上慢很多

linux - 如何从另一台 PC 连接到 VMware?

windows - 批处理 : How to run a program when the computer is idle and stop when it's used?

c# - 哪些 Windows 程序或服务可能会改变文件的 LastAccessed 属性?

amazon-web-services - aws 批处理作业陷入可运行状态,作业定义的内存要求很高

batch-file - 如何批量将文件名转换为小写并更新相应文件中的引用

windows - 对规则进行过滤

java - Spring Batch 重复调用某个项目的处理器

batch-file - 无法在批处理文件中使用 7z 进行压缩