如何在单行中获取bat文件的多个输出

时间:2017-02-14 08:46:05

标签: batch-file

cd C:\Program Files (x86)\PrivateArk\Remote Control Client

for /f "tokens=1-2 delims=," %%1 in (ABC.txt) do (
  c:

  ECHO %%2 >>SNMPLog.txt
  parclient 192.168.0.21 /UsePassFile ParAgent.pass /c %%1   >> SNMPLog.txt

  echo %DATE% >> SNMPLog.txt
  echo %TIME% >> SNMPLog.txt
)

输出日志文件

CPUtilization 
%1.571
Tue 02/14/2017 
13:57:51.49 
2017_ 0_Tu__13_56_12 
DISK Usage
C:\ 9686MB (47.30%)
E:\ 8410MB (82.16%)
Q:\ 1997MB (97.70%)
Tue 02/14/2017 
13:57:51.49 

我是单行输出

DISK Usage C:\ 9686MB (47.30%) Tue 02/14/2017 13:57:51.49 
DISK Usage E:\ 8410MB (82.16%) Tue 02/14/2017 13:57:51.49 
DISK Usage Q:\ 1997MB (97.70%) Tue 02/14/2017 13:57:51.49 

1 个答案:

答案 0 :(得分:0)

@echo off
for /f "tokens=1,2 delims=," %%1 in (abc.txt) do (
  for /f "delims=" %%a in ('parclient 192.168.0.21 /UsePassFile ParAgent.pass /c %%1 ^|find ":\ "') do (
    echo %%a %date% %time%
  )
)

(如果您可以使用缺少的%标志)