读书人

用VBS兑现拖动文件便替换特殊字符

发布时间: 2012-08-15 16:57:16 作者: rapoo

用VBS实现拖动文件便替换特殊字符

?

Set args = WScript.Arguments Set fs = CreateObject("Scripting.FileSystemObject")   If args.Count = 0 Then      MsgBox "You called this script directly, no arguments specified!" Else    For Each argument In args         filename = argument        Const ForReading = 1, ForWriting = 2, ForAppending = 8        If fs.FileExists(filename) Then               Set handle = fs.OpenTextFile(filename,ForReading,True)                Dim line              Do While handle.AtEndOfStream=False                   readStr = handle.readline                   line=line&Replace(readStr,"a","A")&vbNewLine                   'line=Replace(line,"""","'")'替换双引号为单引号                   '其它Reaplace              Loop              Set MyFile= fs.OpenTextFile(filename, ForWriting,True)              MyFile.WriteLine(line)              MyFile.Close        Else            MsgBox filename & " doesn’t exist!"        End If    Next           'MsgBox "Here’s the list of arguments:" & vbCr & listEnd If

读书人网 >VB

热点推荐