Daniele,
Save the Following as MakeRec.vbs. Follow the instructions and it will
Parse your file for you.
''''''''''''''''''''''''''''''''''''''''''''''''''
' MakeRec.Vbs
' auth 091701 mbyerley
' Directions: Execute this file in the directory of the File to Parse
' Syntax: Wscript makerec.vbs "FileName" AddCrLfEveryNoChars
' Example: Wscript MakeRec.vbs "C:\rbfiles\TextFile.txt" 150
' The example would parse the TextFile.txt file and add a CrLf every 150
Chars.
' The File will be saved as "New" + "OriginalFileName". If you do not
provide
' the Full PathName, the Script will figure it out as long as the script
is
' Executed in the directory of the File to be Parsed.
'''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim FSO 'variable to reference the FileSystemObject
Dim TsIn 'stream for the input fileDim FilOut
Dim TSout 'stream for the output file
Dim Fi 'variable to reference the input file
Dim Fo 'variable to reference the output file
Dim strIname
Dim strOname
Dim c
Const ForReading = 1
Const ForWriting = 2
Set FSO = CreateObject("Scripting.FileSystemObject")
With Wscript
If .Arguments.Count < 1 Then
MsgBox "Missing Command Line Argument", vbOKOnly, "Error"
CallItQuits
End If
strIname = .Arguments(0)
c = CInt(.Arguments(1))
End With
If IsNumeric(c) = False Then
MsgBox "Number Of Characters Argument is Not Numeric", vbOKOnly, "Error"
CallItQuits
End If
Err.Clear
OpenOutPut = True
With FSO
strIname = .GetParentFolderName(Wscript.ScriptFullName) & "\" & strIname
strOname = .GetParentFolderName(strIname) & "\NEW" & .GetFileName(strIname)
If .FileExists(strIname) = True Then
Set Fi = .GetFile(strIname)
Set TsIn = Fi.OpenAsTextStream(ForReading, 0)
If .FileExists(strOname) = True Then
.DeleteFile strOname, vbTrue
.CreateTextFile strOname, vbTrue, vbFalse
Set Fo = .GetFile(strOname)
Else
.CreateTextFile strOname, vbTrue, vbFalse
Set Fo = .GetFile(strOname)
End If
Set TSout = Fo.OpenAsTextStream(ForWriting, 0)
End If
End With
With TsIn
While Not .AtEndOfStream
TSout.Write TsIn.Read(c) & vbCrLf
Wend
End With
TsIn.Close
TSout.Close
CallItQuits
Private Sub CallItQuits()
Set FSO = Nothing
Set TsIn = Nothing
Set TSout = Nothing
Set Fi = Nothing
Set Fo = Nothing
MsgBox "Processing Completed"
Wscript.Quit()
End Sub