tags:

views:

68

answers:

5

I have created a file, file1.txt, the content of this file is like "abcdef". I want to read the content of this file and wish to store content in another file "output.txt" using a batch file.

Please let me know how to do it from batch file.

+2  A: 

Your batch file could simply copy the file to the new filename.

copy c:\file1.txt c:\output.txt
Asaph
+1  A: 

It sounds like you just want to copy the file, in which case you can use the following:

COPY "C:\FILE1.TXT" "C:\OUTPUT.TXT"

If that's not what you had in mind, I suggest you clarify the question or dig through the excellent reference here.

mrkj
A: 

Ruchi, your question sounds like you simply want to copy the contents of the file from 'FILE1.TXT' to 'OUTPUT.TXT', is that right? You do not want to change the file in any way? If so, there are lots of ways to do this:

@ECHO OFF
COPY C:\FILE1.TXT C:\OUTPUT.TXT

or

@ECHO OFF
TYPE C:\FILE1.TXT > C:\OUTPUT.TXT

for example.

KingZoingo
A: 

You can do this to overwrite the existing file:

type file1.txt > output.txt

You can do this to append to the existing file:

type file1.txt >> output.txt
beach
A: 
@echo off
rem  -- output file1 to file2 --
type %1 > %2

To use it, say the batch file is named output.bat, use command:

output.bat input.txt output.txt
Raymond