Computing Staff
  • 1

DOS Remove Linefeed And Carriage Return ?

  • 1

I have a pipe separated text file with 2 lines. I need to remove the CR/LF from the last line in the file. I must do this using the DOS batch script that created the file.

Text file:
Line1has|WWW|This is a note CR/LF <— this are not visible
U|12345 CR/LF <– not visible — need to remove this one

Line1has|WWW|This is a note CR/LF <—need to keep this
U|12345

Share

1 Answer

  1. VBScript:

    Const inFilePath = “something.psv”
    Const outFilePath = “out.psv”

    With CreateObject(“Scripting.FileSystemObject”)
    Set inFile = .OpenTextFile(inFilePath)
    Set outFile = .OpenTextFile(outFilePath, 2, True)
    End With
    outFile.WriteLine inFile.ReadLine
    outFile.Write inFile.ReadLine

    • 0