Over-writing a text file (clean up the old content)

Hi All,

I have a script that creates a text file document that I use for another purpose, e.g., renaming folder of files.

What I would like to happen is for the script to always write fresh text items on the same text file document but basically write over the old content. It seems that even if I save over the same document, the old text items remain, with the new text items tacked at the last EOF.
How can I start at the beginning of file and essentially write over the old content?



Hi All,

Never mind. I found the answer in an old post.
Sorry to bother you guys. I should have search more before I posted.

archseed :smiley:

Hi All,

Sorry, I should not have dismissed this thread with barely an explanation.

The post that I found by searching this forum suggested using the expression “set eof to 0”, that is zero. This is to enable to begin writing on the text window at the top of the text file instead of at the end of the file (eof).

While that suggestion did indeed enable my script to write at the beginning of the text file, it did not quite do the job of erasing the content of my text file. I had to do a write to file onto a fresh text window and save a copy as a text file to use as a new editing template. This served the purpose of my script.

I hope this post could provide some useful information to those who might meet a similar dilemma.


archseed :o

“set eof to 0” sets the end of the file to 0 ” that is, to the same as the beginning of the file. This effectually makes the file empty. When eof is set lower than the current value of the file position pointer (which scripts can’t access directly), the file position pointer is set to the new eof. Since that’s the same as the beginning of the file here, the next write starts at the beginning of the empty file.

I don’t understand what you mean by “writing on the text window”.