Reputation: 11
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.
Upvotes: 1
Views: 338
Reputation: 609
@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
Upvotes: 0
Reputation: 796
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.
Upvotes: 0
Reputation: 8640
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
Upvotes: 0
Reputation: 3101
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.
Upvotes: 2
Reputation: 162801
Your batch file could simply copy the file to the new filename.
copy c:\file1.txt c:\output.txt
Upvotes: 3