user10795548
user10795548

Reputation:

How save separate part of the output of command in cmd

I'm trying to save only a value in output of a command written in batch file.

Here is the code which I have already written.

gencompress 01.dat > temp.txt

the output of this likes below..

Unconditionally compress 01.dat.
Searching for approximate repeats!
The compressed filename is 01.GEN!

0.005873%
..
93.733850%
99.982382%
..

 The size of original file is 17028 bytes.
 The size of compressed file is 4263 bytes.
 The compression ratio is 74.964764%.
    (defined by 1-|compressed_file|/|original_file|)

 Note: To verify the correctness of compression, you need follow the next two steps and then see what happens.
       1>  gendecompress  original_file.gen  [-c reference_file] 
       2>  comparetwofile  original_file  original_file.out 

But I want to store value 4263 (size of the compressed file which is in the middle of output) only to a text file. How I retrieve that value from output.

Thanks for any help.

Upvotes: 0

Views: 63

Answers (1)

Stephan
Stephan

Reputation: 56180

filter the output for the relevant line and use the right token:

for /f "tokens=7" %%a in ('gencompress 01.dat^|find "size of compressed"') do >temp.txt echo %%a

Upvotes: 1

Related Questions