Open a file, save it and close it using a Batch File

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
the_caretaker
Posts: 3
Joined: 27 Sep 2012 08:53

Open a file, save it and close it using a Batch File

#1 Post by the_caretaker » 27 Sep 2012 08:59

Hi,

I am trying to write a batch file to open a file(.txt) in a specified location,save the file and then close the file again.

Is it possible to execute these commands using a batch file? I can write the command to open, but cannot seem to save and close it.

Thanks in advance.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Open a file, save it and close it using a Batch File

#2 Post by foxidrive » 27 Sep 2012 10:26

the_caretaker wrote:I am trying to write a batch file to open a file(.txt) in a specified location,save the file and then close the file again.

Is it possible to execute these commands using a batch file? I can write the command to open, but cannot seem to save and close it.


How are you opening it?
Do you want to add text to an existing file?


This will add a line at the bottom of a file.txt file. It automatically gets saved.

Code: Select all

>>file.txt echo new line at the bottom

the_caretaker
Posts: 3
Joined: 27 Sep 2012 08:53

Re: Open a file, save it and close it using a Batch File

#3 Post by the_caretaker » 27 Sep 2012 10:37

Hi, thanks for the replies.

No I don't need to add any text, I just need to save it i.e. update Date Modified.

Thanks

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Open a file, save it and close it using a Batch File

#4 Post by Squashman » 27 Sep 2012 11:05

Code: Select all

COPY /B file.txt +,,

Going forward please state what your intended goal is in your question.

the_caretaker
Posts: 3
Joined: 27 Sep 2012 08:53

Re: Open a file, save it and close it using a Batch File

#5 Post by the_caretaker » 28 Sep 2012 01:26

Thanks Squashman,
this was really helpful.

Post Reply