Remove last carriage return

namliam

The Mailman - AWF VIP
Local time
Today, 18:50
Joined
Aug 11, 2003
Messages
11,695
OK, so I have a text file and for some idiotic reason the last carriage return needs to be removed...

Please see test_bad and test_good attachments for the general idea, if you dont get it allready.
I can find plenty of scripts to remove empty lines, i.e.
Code:
@ECHO OFF
FOR /F "usebackq delims=" %%a in ("test.txt") DO (
ECHO.%%a
)

or
Code:
Findstr /v ^^$ test.txt > test_clean.txt
However I cannot seem to find a way to remove the last line in the file, my guess is I want to 'simply' remove the last carriage return and I can think of ways to do it in VBA, but this needs to be done in the command line

Anyone have any clue?
 

Attachments

Is this still a problem or have you solved it already?
 
Is this a one time deal with one file? Or a repeating problem with many files?

Are you writing software to read and process this file? If so, have your software ignore the last line.
 

Users who are viewing this thread

Back
Top Bottom