VBS Script to remove carriage returns from large file.

Posted on 2013-01-02
Last Modified: 2013-01-07

As you can see in this the example above are many carriage returns and I need to remove them all. I have attached the vbs code that I tried with no change to the file.
Question by:dondudley
  • 4
  • 2
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38738179
Are you certain the target file has CRLF as its line endings? Perhaps the file only uses LF, at which point your Replace call would not find anything.

Author Comment

ID: 38738209
Here is an example of the original code and notice that it only has one extra carriage return.


In my file it is all together in a text file and where the 59; is there is actually a carriage return between the 9 and the semicolon but here is shows different but that is what I need to remove.
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38738331
Try altering line 9 to:

strNewText = Replace(Replace(strText, chr(013), ""), chr(010), "")   ' chr(010) = line feed chr(013) = carriage return 

Open in new window

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.


Author Comment

ID: 38738573
Tried it but didn't seem to work. I would like to send the original file to you but it is business confidential. Is there anyway I can get the file to you without anyone seeing it?


Accepted Solution

dondudley earned 0 total points
ID: 38738925
I did get it to work, sorry I must have had something wrong but it is working now.

Thank you very much.


Author Closing Comment

ID: 38750313
It was a great catch in the code and he fixed it first try.

Thanks again,

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question