Computing.Net > Forums > Programming > DOS - Text File

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

DOS - Text File

Reply to Message Icon

Name: Gyro
Date: May 27, 2009 at 11:45:46 Pacific
OS: Windows XP
CPU/Ram: 2.66/3Gig
Product: Dell DESKTOP
Subcategory: Batch
Comment:

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 :)



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: May 27, 2009 at 12:14:08 Pacific
Reply:

Hard to tell without the file. You can zip it up and send it.


http://www.sendthisfile.com


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

M2


0

Response Number 2
Name: Gyro
Date: May 27, 2009 at 12:47:56 Pacific
Reply:

99999999991111111111
66666666665555555555


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...


0

Response Number 3
Name: Judago
Date: May 27, 2009 at 14:34:29 Pacific
Reply:

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.


0

Response Number 4
Name: Gyro
Date: May 27, 2009 at 15:23:26 Pacific
Reply:

99999999991111111111
66666666665555555555
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... :)


0

Response Number 5
Name: Mechanix2Go
Date: May 27, 2009 at 15:31:26 Pacific
Reply:

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.

M2


0

Related Posts

See More



Response Number 6
Name: ghostdog
Date: May 27, 2009 at 17:47:42 Pacific
Reply:

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):
    line=line.strip()
    if line!=chr(26): #check control Z
        print line

save as myscript.py, and on command line
c:\test>python myscript.py

this way, it goes through the file only once.

0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: DOS - Text File

HTML How do I write to text file? www.computing.net/answers/programming/html-how-do-i-write-to-text-file/9317.html

Pass text file to DOS command www.computing.net/answers/programming/pass-text-file-to-dos-command/17398.html

set var from a text file in dos www.computing.net/answers/programming/set-var-from-a-text-file-in-dos/20045.html