delete last CR and LF from text file

February 22, 2010 at 08:54:05
Specs: Windows Server 2003
I am running Windows Server 2003. I have a dos batch file the copies a file in one location to another location every night. The program that creates the file adds a CR and an LF at the end, I need to remove these. The file size and data varies every night.

See More: delete last CR and LF from text file

Report •

#1
February 22, 2010 at 15:06:12

Report •

#2
February 22, 2010 at 16:16:37
If CR and LF are text characters as you have typed them, or are represented by typeable characters otherwise, you can remove the CR and LF or whatever typeable characters in existing batch or text files (or any file Wordpad can read) by editing the file in Wordpad.
Start Wordpad.
Select File at top left, Open, set it to All documents.
Go to the *.bat or *.txt file (or any file Wordpad can read) and Open it (Wordpad won't execute *.bat files) .
Select Edit at top left - Replace - type e.g. CR, don't type anything in the Replace with box, click on the box beside Match whole word only to insert a checkmark.
Click on Find next to toggle through all instances of e.g. CR.
It will toggle back to the first instance found eventually.
- if it is in the body of the file as well as in it separately, click on Replace for each instance where you want to replace it with nothing.
- if it is NOT in the body of the file as well as in it separately, click Replace All when any instance of it is found to replace all instances with nothing.


Report •

#3
February 24, 2010 at 06:23:00
I do know how to do it manually that is how I am doing it now when it has to be done but, I need to use Perl or DOS to do it automatically after the file is created and before it gets automatically transferred to the different location. I do like to take vacations.

Report •
Related Solutions


Ask Question