How is .txt file different from a .dat file in C?

Creating a txt file from a bat file.?

  • hey, im making a batch file to run a few things, but i want it to create a file in a set location from the bat file. I have found the coding i need which is: echo hello world > c:\hi.txt type c:\hi.txt > %var1% echo contents of file "hi.txt"...%var1% The only issue is, that i need to have multiple lines....i.e for it to say something like: hello world 1 2 3 4 but i dnt know how to do that, if you type that in the bat files it doesnt work

  • Answer:

    Echo hello world > c:\hi.txt Echo 1 2 >>c:\hi.txt

kyle at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Note that the default security settings on Vista/Win7 do not allow users (even admins) to create files in the root of a drive, so trying to create c:\hi.txt will give an access denied message, unless you've changed the drive permissions. Most people don't, so if you share this with friends, it might not work on their system. You should instead create a folder to use, then create your file in that, e.g. Set _Folder=C:\FunStuff If NOT Exist "%Folder%" MD "%Folder%" echo hello world > "%Folder%\hi.txt" Also note that the space between world and > will be echoed to the file. If you don't want the trailing space, remove the space, or put the redirection at the start of the line: echo hello world> "%Folder%\hi.txt" >"%Folder%\hi.txt" echo hello world

The Outcaste

To append to the file you use >> instead of > This may help you. There are a few pages about batch files: http://www.robvanderwoude.com/redirection.php

probablygraham

See number 2

ray_diator

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.