Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Making a file using Batch Files

  1. Feb 12, 2012 #1
    How do i create a .txt file using a batch file with something written on it.

    For example, i want to write this:-


    It has multiple lines and '>', so echo (text) >> test.txt doesnt work.

    Is there a better way?
  2. jcsd
  3. Feb 12, 2012 #2


    User Avatar

    Staff: Mentor

  4. Feb 12, 2012 #3


    User Avatar

    Staff: Mentor

    Depending on the complexity of your task, it may be sufficient to use this technique:

    Code (Text):
    It's usually enough to enclose it between two %%"%% blocks, like this:

    echo %%"%% something ii >>newfile %%"%% >reg.bat
    It may not look pretty but it usually works just fine.

    If %%"%% doesn't seem to do what you want, try single percents like this:

    Code (Text):
    echo %"% something ii >>newfile %"% >reg.bat
    I no longer have a MSDOS system to try stuff out. You are likely to discover there are other characters that cause you problems when you try to echo them to a second file, too.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook