Is it possible to output 开发者_如何学Goinformation from a batch file, with multiple outputs.
E.g.
test.bat > output.txt
then 20 seconds later create a new file
test.bat > output2.txt
etc. (With the process still running)
No need to give up just cause you're limited to batch. This can be achieved quite easy
@ECHO off
:: Check if the script has ran before, and set the iteration
IF EXIST next.txt (
FOR /F "tokens=1" %I in (next.txt) DO SET /A _result=%I+1> next.txt
) else (
SET /A _result=^1> next.txt
)
:: Now the iteration is stored in a variable named %_result%
echo test > output%_result%.txt
If you download a copy of sed for windows it shouldn't be too hard to achieve a unique name with chronology.
time /t | sed "s/:/_/g" | sed "s/ /_/">>time.txt
for /F "tokens=*" %%I IN (time.txt) DO echo test >> output-%%I.txt
Note: if you're using Win Vista/7 you'll need to change this to %I instead of %%I
精彩评论