VBS Script to remove carriage returns from large file.

a









b
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.
Remove--returns.vbs
dondudleyAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
dondudleyConnect With a Mentor Author Commented:
I did get it to work, sorry I must have had something wrong but it is working now.

Thank you very much.

Don
0
 
käµfm³d 👽Commented:
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.
0
 
dondudleyAuthor Commented:
Here is an example of the original code and notice that it only has one extra carriage return.

2.80;176;4.93;01/20/2012
;
00904-5125-59
;


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.
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
käµfm³d 👽Commented:
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

0
 
dondudleyAuthor Commented:
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?

Thanks,
Don
0
 
dondudleyAuthor Commented:
It was a great catch in the code and he fixed it first try.

Thanks again,
Don
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.