how to indent the outputs in dos batch file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Guest

how to indent the outputs in dos batch file

#1 Post by Guest » 16 Sep 2006 14:04

I am trying to make the contents of a text file look nice, and the requirement is that the first line is NOT necessarily indented, but the following lines should be indented with three spaces.
How can I realize this function? Thank you. :)

DosItHelp
Expert
Posts: 239
Joined: 18 Feb 2006 19:54

#2 Post by DosItHelp » 21 Sep 2006 20:36

It's easy when the source of the indended content is another file.
I.e.:

If names.txt containes names like:

Code: Select all

Daniel
Ollie
Sam
Nina
Victor
Cris


Then code like this ...

Code: Select all

echo.List of Names:>list.txt
for /f "tokens=* delims=" %%a in (names.txt) do echo.   %%a>>list.txt


... will create an output like this ...

Code: Select all

List of Names:
   Daniel
   Ollie
   Sam
   Nina
   Victor
   Cris



DOS IT HELP? :wink:

Post Reply