Windows Batch script * (star) read as text?

大兔子大兔子 提交于 2019-12-02 11:28:01

for /f expects a single file name and is not capable of using wildcards. Use another plain for around:

for %%X in (HRV*.txt) do (
  for /F "tokens=*" %%A in (%%X) do (
    ... etc. etc.
  )
)

by the way: your way of redirecting is very slow. The destination file is opened, one line is written and the file is closed again. Opening and closing a file is very time consuming. You can avoid it by opening and closing it just one time. Instead of:

for /l %%a in (1,1,10000) do (
  echo something>>file.txt
)

which needs about 27 seconds, do:

(
  for /l %%a in (1,1,10000) do (
    echo something
  )
)>file.txt

which needs about 170 ms. (Ymmv - times depends on your computer system)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!