China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-11 08:01
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to output the _final_ screen display from a batch file to a file? View 1,110 Replies 11
Original Poster Posted 2009-02-07 16:51 ·  中国 浙江 杭州 电信
新手上路
Credits 17
Posts 9
Joined 2008-03-29 18:01
18-year member
UID 114369
Gender Male
Status Offline
As the title says.

For example, there is a bat file. After it finishes running and pause is reached, I can Select All in the cmd window, copy it, and save it as text.
What I want is a way to save this text automatically.

An example will make it easier to explain.The example is only for illustration, not a request for a solution to this specific case.
Suppose there is a batch file that converts wav to flac.
flac.exe test.wav
While it runs, the screen keeps updating with the progress. When it finishes, it gives final information such as the final file size and compression ratio. (If that's not clear enough, please look at the pictures.
During run 1:


During run 2:


Final screen display:


This final screen display information is what I want.

If I use 2>log, then the file I get is something like this:
flac 1.2.1, Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
welcome to redistribute it under certain conditions. Type `flac' for details.


wavtest.wav: 3% complete, ratio=0.251
wavtest.wav: 5% complete, ratio=0.280
wavtest.wav: 7% complete, ratio=0.279
...middle omitted
wavtest.wav: 95% complete, ratio=0.450
wavtest.wav: 98% complete, ratio=0.452
wavtest.wav: wrote 4770849 bytes, ratio=0.445


But what I want is what is shown in the final screen display, without so many lines in the middle, in a file in a format like this:
flac 1.2.1, Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
welcome to redistribute it under certain conditions. Type `flac' for details.

wavtest.wav: wrote 4770849 bytes, ratio=0.445


The above example is only for illustration, not a request for a solution to this specific case.

Is there any command or tool that can do this?

Please advise. Thanks.

PS, what I want is to get such a file directly, not to process the log with a tool after it finishes.

[ Last edited by noe on 2009-2-8 at 23:07 ]
Floor 2 Posted 2009-02-07 17:00 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore
Floor 3 Posted 2009-02-07 21:04 ·  中国 浙江 杭州 电信
新手上路
Credits 17
Posts 9
Joined 2008-03-29 18:01
18-year member
UID 114369
Gender Male
Status Offline
Originally posted by slore at 2009-2-7 05:00 PM:
findstr /v "%%" log

Thanks.
But the flac example I gave above was only an example. Using findstr does not seem to work generally for other cases.
Is there a more generally applicable method?
Floor 4 Posted 2009-02-07 21:40 ·  中国 广东 东莞 电信
银牌会员
★★★
批处理编程迷
Credits 1,916
Posts 752
Joined 2008-12-28 04:30
17-year member
UID 135147
Gender Male
From 广西
Status Offline
Is it the first three lines and the last line?
精简
=> 个人网志
Floor 5 Posted 2009-02-08 12:50 ·  中国 浙江 杭州 电信
新手上路
Credits 17
Posts 9
Joined 2008-03-29 18:01
18-year member
UID 114369
Gender Male
Status Offline
Originally posted by netbenton at 2009-2-7 09:40 PM:
Is it the first three lines and the last line?

Hello. What I want to find is a general solution.
The example here is only for ease of explanation and use.

What I need is what the title says: output the _final_ screen display to a file.
Floor 6 Posted 2009-02-08 13:00 ·  中国 广东 东莞 电信
银牌会员
★★★
批处理编程迷
Credits 1,916
Posts 752
Joined 2008-12-28 04:30
17-year member
UID 135147
Gender Male
From 广西
Status Offline
Give another different example and let us see. If the program is supposed to be general, then you have to find what different examples have in common and handle that; otherwise, it can't be written.
精简
=> 个人网志
Floor 7 Posted 2009-02-08 20:04 ·  中国 浙江 杭州 电信
新手上路
Credits 17
Posts 9
Joined 2008-03-29 18:01
18-year member
UID 114369
Gender Male
Status Offline
Originally posted by netbenton at 2009-2-8 01:00 PM:
Try giving another different example. For a program to be generic, it has to find what is common between different examples and handle that; otherwise, it can't be written.

Hello.
Let me put it another way.
There is a bat file. After it finishes running and pause is reached, I can Select All in the cmd window, copy it, and save it as text.
What I want is a way to save this text automatically.
What I do not want is a method for how to process the log file after redirecting stderr to a log file.
Floor 8 Posted 2009-02-08 20:09 ·  中国 北京 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 9 Posted 2009-02-08 23:05 ·  中国 浙江 杭州 电信
新手上路
Credits 17
Posts 9
Joined 2008-03-29 18:01
18-year member
UID 114369
Gender Male
Status Offline
Originally posted by yishanju at 2009-2-8 08:09 PM:
flac.exe test.wav|findstr /c:"wrote">>log.txt

Thanks for your reply.
But it would be better if you could read the post before replying; it would save both your time and mine.
What I want is not a solution for this specific example.
Floor 10 Posted 2009-02-08 23:21 ·  中国 北京 海淀区 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
You really are hard to understand

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 11 Posted 2009-02-08 23:23 ·  中国 北京 海淀区 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
Could you re-upload the pictures
Upload pictures that can be seen clearly

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 12 Posted 2009-02-08 23:33 ·  中国 广东 东莞 电信
银牌会员
★★★
批处理编程迷
Credits 1,916
Posts 752
Joined 2008-12-28 04:30
17-year member
UID 135147
Gender Male
From 广西
Status Offline
@echo off
::%1 is the specified output filename, otherwise output to abcec.txt
::Batch file for saving the entire screen under DOS, does not support Chinese
goto :begin
f 100 l14 B8 00 B8 50 1F BF 00 02 B9 D0 07 BD 02 08 BA 50 00 AD 3C 20
f 114 l14 75 03 43 75 02 31 DB AA 4A 75 0D B8 0D 0A 29 DF 29 DD 31 DB
f 128 l0e AB BA 50 00 E2 E3 06 1F 89 E9 31 DB 90 90
t=100
g 134
w 200
q
:begin
if '%1'=='' set of=abcec.txt
debug %1%of%<%~f0>nul
start notepad %1%of%

[ Last edited by netbenton on 2009-2-9 at 00:33 ]
精简
=> 个人网志
Forum Jump: