Redirect output of command in for loop of batch script

前端 未结 2 1325
别跟我提以往
别跟我提以往 2020-12-30 03:15
...
for /F %%F in (\'dir /B %* 2> nul\') do (
...

What I\'m attempting to do here is discard the err output of the command (and loop over the st

相关标签:
2条回答
  • 2020-12-30 03:41

    in this case you need to escape the > like this

    for /F %%F in ('dir /B %* 2^> nul') do (
    
    0 讨论(0)
  • 2020-12-30 04:04

    I believe you need a delimiting space between the "2" and the ">". Without that delimiter my dir test output still displayed on the screen. Furthermore, I believe that by sending the output of the dir command to null will not provide any data back for the set to process.

    0 讨论(0)
提交回复
热议问题