Windows to Unix

This script converts a Windows text file into a Unix text file by removing the Ascii character 13 using Regular Expressions. The script is just a standard vbs script and takes the file name as its first parameter and an output file as its second parameter. If the second parameter is not provided, then it will replace the current file. I have a VB 6 program that does that same thing floating around but I find the script much easier to work with if I need to make minor adjustments.

function ReplaceChar(byval sText, byval sFind, byval sReplace) dim oQre set oQre = new regexp oQre.Pattern = sFind oQre.Global = true sText = oQre.Replace(sText, sReplace) set oQre = nothing ReplaceChar = sText end function dim x, y set args = WScript.Arguments if args.Count = 1 then x = args.Item(0) elseif args.Count > 1 then y = args.Item(1) else MsgBox "no file selected" end if if x <> "" then Dim oFSO Dim tf Dim s Set oFSO = CreateObject("Scripting.FileSystemObject") Set tf = oFSO.OpenTextFile(x , 1) s = tf.ReadAll tf.Close s = ReplaceChar(s, "\r", "") if y = "" then y = oFSO.GetParentFolderName(x) & "\" & oFSO.GetBaseName(x) Set tf = oFSO.OpenTextFile(y, 2, true) tf.Write s tf.Close end if
Testimonals
I can't envision an easier program to use to record trades.
ProductsMore ...
Electronic Trade Journal
Risk/Reward Calculator
Stock Calculator
Subscription Manager
ArticlesAll
Programming Guidelines
Regular Expressions
Display Source in HTML
HTML-Safe Color Table
Quotes in a HTML TextBox
Convert Windows File to Unix
Shortcuts in the SendTo Menu
Backup and Scan Hard Drive