Computing.Net > Forums > Programming > creating a file using a .bat file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

creating a file using a .bat file

Reply to Message Icon

Name: djas
Date: August 13, 2004 at 13:48:56 Pacific
OS: Windows XP
CPU/Ram: n/a
Comment:

hi, im new to .bat file but have already learned quite a bit about them but have hit a snag.
i need to know if a .bat file can create a file e.g. "New Text Document.txt" and if so how
thanx in advance

djas




Sponsored Link
Ads by Google

Response Number 1
Name: BlueRaja
Date: August 13, 2004 at 14:38:23 Pacific
Reply:

You could try something like
@CON >> "new text document.txt"
Although it gives you an error, it *does* create a blank file...


0

Response Number 2
Name: djas
Date: August 13, 2004 at 14:48:11 Pacific
Reply:

it seems to work perfectly for me what error is it that you get

djas


0

Response Number 3
Name: djas
Date: August 13, 2004 at 14:52:45 Pacific
Reply:

also is there a way edit the file from a .bat file
thanx

djas


0

Response Number 4
Name: BlueRaja
Date: August 13, 2004 at 18:37:28 Pacific
Reply:

echo Hello world! >> "new text document.txt"


0

Response Number 5
Name: Mechanix2Go
Date: August 13, 2004 at 23:27:40 Pacific
Reply:

Hi,

@con is messy

Use @echo off>newfile.txt

Edit a file from a .bat?

Are you ready for debug?



0

Related Posts

See More



Response Number 6
Name: djas
Date: August 14, 2004 at 00:53:43 Pacific
Reply:

what do you mean am i ready?

djas


0

Response Number 7
Name: BlueRaja
Date: August 14, 2004 at 15:05:34 Pacific
Reply:

lol
debug is used for writing and/or debugging assembly programs.


0

Response Number 8
Name: djas
Date: August 15, 2004 at 02:58:58 Pacific
Reply:

how does the debug command work?


djas


0

Response Number 9
Name: xboxking02
Date: August 15, 2004 at 04:44:55 Pacific
Reply:

dont worry about it. debug more of for programs than text files.

try this:


@echo off
echo hello world > c:\hi.txt
type c:\hi.txt > %var1%
echo contents of file "hi.txt"...%var1%


@echo off... turns off echo

echo hello world > c:\hi.txt...puts the text "hello world" in the file hi.txt in the C folder.

type c:\hi.txt > %var1%...this takes the contents of hi.txt and sticks it into the variable %var1%.

and that last line just tells us whats in the file using that %var1% variable.

you proabably knew all that but oh well.



0

Response Number 10
Name: djas
Date: August 15, 2004 at 05:33:02 Pacific
Reply:

thanx anyway though

djas


0

Response Number 11
Name: xboxking02
Date: August 15, 2004 at 06:06:04 Pacific
Reply:

yeah I figure if someguy is doing a search for making a bat file and they see my code it'll give em a little extra knowledge


0

Response Number 12
Name: djas
Date: August 15, 2004 at 09:28:59 Pacific
Reply:

i think i can use this code instead of some of my other files thanx

djas


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: creating a file using a .bat file

can I block a port with a Bat file www.computing.net/answers/programming/can-i-block-a-port-with-a-bat-file/15905.html

How to delete a file in a bat www.computing.net/answers/programming/how-to-delete-a-file-in-a-bat/18452.html

add a .bat file to right click contents men www.computing.net/answers/programming/add-a-bat-file-to-right-click-contents-men/19169.html