batch-file Creating Files using Batch Saving the output of many commands


Example

Using many ECHO commands to create a batch file:

(
  echo echo hi, this is the date today
  echo date /T
  echo echo created on %DATE%
  echo pause >nul
)>hi.bat

The command interpreter treats the whole section in parenthesis as a single command, then saves all the output to hi.bat.

hi.bat now contains:

echo hi, this is the date today
date /T
echo created on [date created]
pause >nul