【问题标题】:Windows, runnig script with variable paramameter, for cycleWindows,带有可变参数的运行脚本,用于循环
【发布时间】:2013-08-12 16:22:35
【问题描述】:

有一个需要处理的文本文件列表。他们的名字是

samples\file_1.txt
...
samples\file_100.txt

一个脚本使用两个参数调用文件 test.exe。第一个和第二个参数代表输入和输出文件名,随着增量1变化,参数-t是固定的:

test.exe  \input\file_1.txt \output\file_1.txt -t
...
test.exe  \input\file_100.txt \output\file_100.txt -t

如何写一个简化版的脚本,一个一个的处理文件,使用for循环?

我使用 Python 脚本解决了这个问题,但希望有更通用的方法...

【问题讨论】:

  • 这听起来很像我的家庭作业。你试过什么了?你读过help for吗?

标签: for-loop command-line batch-file window


【解决方案1】:
@echo off
cd /d "c:\samples\input"
md "..\output" 2>nul
for %%a in (*.txt) do (
test.exe "%%a" "..\output\%%a" -t
)

【讨论】:

    猜你喜欢
    • 2021-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-22
    • 1970-01-01
    • 2012-08-21
    相关资源
    最近更新 更多