Page 1 of 1

how to indent the outputs in dos batch file

Posted: 16 Sep 2006 14:04
by Guest
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. :)

Posted: 21 Sep 2006 20:36
by DosItHelp
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: