Remove last carriage return (1 Viewer)

namliam

The Mailman - AWF VIP
Local time
Today, 05:51
Joined
Aug 11, 2003
Messages
11,680
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

  • test_good.txt
    24 bytes · Views: 160
  • test_bad.txt
    26 bytes · Views: 143

Hotaru

New member
Local time
Yesterday, 23:51
Joined
Mar 12, 2008
Messages
2
Is this still a problem or have you solved it already?
 

bulrush

Registered User.
Local time
Yesterday, 23:51
Joined
Sep 1, 2009
Messages
209
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

Top Bottom