Yes you can. The code below converts unix to dos fixing the Cr and Linefeed
so they are dos format.
Unix files only need a carriage return, dos uses both Carriagge return and
linefeed.
If you just want to modify the code below as required. To read the UNIX
file you need to open the file in binary mode andread one character at a
time. the end of the line would be when yo uget to the CR.
Sub fixcrlf()
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const MyPath = "C:\temp\"
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim CR As String
Dim LF As String
CR = Chr(13)
LF = Chr(10)
Set fsread = CreateObject("Scripting.FileSystemObject")
Set fswrite = CreateObject("Scripting.FileSystemObject")
ReadFileName = "intext.txt"
WriteFileName = "outtext.txt"
'open files
ReadPathName = MyPath + ReadFileName
Set fread = fsread.GetFile(ReadPathName)
Set tsread = fread.OpenAsTextStream(ForReading, TristateUseDefault)
WritePathName = MyPath + WriteFileName
fswrite.CreateTextFile WritePathName
Set fwrite = fswrite.GetFile(WritePathName)
Set tswrite = fwrite.OpenAsTextStream(ForWriting, TristateUseDefault)
OutputLine = ""
FoundCR = False
Do While tsread.atendofstream = False
MyChar = tsread.Read(1)
Select Case MyChar
Case LF
If FoundCR = False Then
tswrite.write CR
Else
FoundCR = False
End If
Case CR
If FoundCR = True Then
tswrite.write LF
Else
FoundCR = True
End If
Case Else
If FoundCR = True Then
tswrite.write LF
FoundCR = False
End If
End Select
tswrite.write MyChar
Loop
tswrite.Close
tsread.Close
End Sub