DOS - Text File

May 27, 2009 at 11:45:46
Specs: Windows XP, 2.66/3Gig
I don't have the tools or know what tools will actually tell me what the little box is at the end of a text file that I have created via a data base export... but I need to get rid of this last line, which is basically blank, but must have some sort of carriage return or end of file character that I can not read... (the little box, as appears through notepad) I have tried running a copy /b but I end up with the same file... My DOS skills have faded over the years... and do not remember how to get rid of this "little box".. Thanks... Humbled, Gyro :)

See More: DOS - Text File

Report •

May 27, 2009 at 12:14:08
Hard to tell without the file. You can zip it up and send it.

If at first you don't succeed, you're about average.


Report •

May 27, 2009 at 12:47:56

Thanks for the site to send... but the site indicates that I need an e-mail address to send to... but it works the same on all files... whether in the 750,000 I'm dealing with or something simple as above... but the little box takes on a new flavor here...

Can forward this file to anyone... Thanks...

Report •

May 27, 2009 at 14:34:29
That posted character is ^Z and was a pretty standard end of file character. There is an easy way to get rid of it if you don't mind having an extra empty line at the end:

>>filename echo.

Of course this is impractical if you are appending to the file again later, but if you append anything the ^Z will be replaced with it on xp.

Report •

Related Solutions

May 27, 2009 at 15:23:26
1 file(s) copied

Thanks... Much closer... This is the new output... I am at home now, but created a simple data base like before, exported it and then applied the following command to receive the results above...

This is the command I used...

copy test.txt >> test1.txt echo

Obviously I have done something wrong... or put another way... I need this copy step to be able to rename from a stored memory variable... (written from with a data base language... stepping out to DOS to create the file, which I do not believe will be a problem)

From my memory... if this is an end of file, then perhaps this is like the control Z... too many years have passed... daaaa

Thanks for your help... :)

Report •

May 27, 2009 at 15:31:26
For XP, not DOS:

@echo off > newfile & setLocal EnableDelayedExpansion

for /f "tokens=1 delims= " %%a in ('find /c /v "" ^< myfile') do (
set last=%%a

set N=0

for /f "tokens=1* delims=[]" %%a in ('find /n /v "" ^< myfile') do (
set /a N+=1
if !N! lss !last! echo.%%b>> newfile

If at first you don't succeed, you're about average.


Report •

May 27, 2009 at 17:47:42
if your files are big, using M2's batch will be quite inefficient as it uses find command twice just to get to your last character. In fact,you just need to go through your file once. here's an alternative using Python if you can download and install it.
import fileinput 
for line in fileinput.FileInput("file",inplace=0):
    if line!=chr(26): #check control Z
        print line

save as, and on command line

this way, it goes through the file only once.

Report •

Ask Question