formating string output?

D

djc

I have a batch file that appends to a log file. I use the find command a lot
on this file to check things out. What I would like to do is format the
output to make is look nicer. For example the text file has several fields
delimited with a comma. I would like to show field headings and evenly space
the output into nice columns.

whats the best way to go about doing this?

thanks.
 
M

Matthias Tacke

djc said:
I have a batch file that appends to a log file. I use the find command a lot
on this file to check things out. What I would like to do is format the
output to make is look nicer. For example the text file has several fields
delimited with a comma. I would like to show field headings and evenly space
the output into nice columns.

whats the best way to go about doing this?

thanks.
Have a look at timo's cmdfaq. There are several related topics.
Some grew out of threads here, so read here or search via google:
http://groups.google.com/groups?group=alt.msdos.batch.nt&q=justify

HTH
 
J

Jerold Schulman

I have a batch file that appends to a log file. I use the find command a lot
on this file to check things out. What I would like to do is format the
output to make is look nicer. For example the text file has several fields
delimited with a comma. I would like to show field headings and evenly space
the output into nice columns.

whats the best way to go about doing this?

thanks.


If you were starting fresh, and you have 3 fields call

field One max length 40
field two max length 30
field three max length 50

set fh1=Field One
set fh1=%fh1:~0,40%,
set fh2=Filed Two
set fh2=%fh2:~0,30%,
set fh3=Filed Three
set fh3=%fh3:~0,50%
if not exist logfile.log @echo %fh1%%fh2%%fh3%>logfile.log

.....
.....
set f1=%var1:~0,40%,
set f2=%var2:~0,30%,
set f3=%var3:~0,50%
@echo %f1%%f2%%f3%>>logfile.log
go to ....




Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
D

djc

Thanks

Jerold Schulman said:
If you were starting fresh, and you have 3 fields call

field One max length 40
field two max length 30
field three max length 50

set fh1=Field One
set fh1=%fh1:~0,40%,
set fh2=Filed Two
set fh2=%fh2:~0,30%,
set fh3=Filed Three
set fh3=%fh3:~0,50%
if not exist logfile.log @echo %fh1%%fh2%%fh3%>logfile.log

....
....
set f1=%var1:~0,40%,
set f2=%var2:~0,30%,
set f3=%var3:~0,50%
@echo %f1%%f2%%f3%>>logfile.log
go to ....




Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top