Close TXT file in batch

November 13, 2009 at 10:47:29
Specs: Windows XP
Hi,

Is there a way to close a TXT file newly created so that it may be reread again?

Or should I make a 2nd batch file?

Thanks!


See More: Close TXT file in batch

Report •


#1
November 13, 2009 at 13:56:34
Turn off computer
Turn on computer
Kidding!

Try doing some reading on terminating windows tasks. The pros will be able to help you further


Report •

#2
November 13, 2009 at 14:04:10
I remember reading something on this forum about switching tasks. I tried to find it now and cant... sorry.

Report •

#3
November 13, 2009 at 14:14:20
Try something like this:
taskkill /f /im notepad.exe

it closed my instance of notepad.exe


Report •

Related Solutions

#4
November 13, 2009 at 15:25:30
What exactly do you mean by "close"? How was it created?
How is it currently "open"?

Report •

#5
November 13, 2009 at 17:30:27
@OP, commands like more, type opens files internally and "closes" them as they finished reading them. If you want to reread them, execute the commands again. Otherwise, you if you want to do hardcore file manipulation where you can have complete control of where in the file you want to go, use a better programming language. eg Perl, Python.

GNU win32 packages | Gawk


Report •

#6
November 13, 2009 at 17:46:17
Thanks ghostdog.

Report •

#7
November 14, 2009 at 05:29:32
One other thing.

If you do this:

echo One more line>>file.txt

Then that opens the file, appends a line to it, and closes it. All
in one command. Even if you have that command in a loop, it
opens it, writes to it, and closes it, each time through the
loop.

The point is that the file is already closed by the time the next
command is executed. So you can do this without any
problem:

echo One more line>>file.txt
type file.txt


Report •


Ask Question