最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

利用vbscript腳本修改文件內(nèi)容,此適用于自動化的操作中

 更新時間:2006年12月27日 00:00:00   作者:  
利用vbscript腳本修改文件內(nèi)容,此適用于自動化的操作中

'新建一個Replace.vbs腳本,腳本內(nèi)容如下,程序運行時輸入三個參數(shù):查找內(nèi)容,替換內(nèi)容,文件 

復(fù)制代碼 代碼如下:
Dim FileName, Find, ReplaceWith, FileContents, dFileContents  
Find = WScript.Arguments(0)  
ReplaceWith = WScript.Arguments(1)  
FileName = WScript.Arguments(2)  

'讀取文件  
FileContents = GetFile(FileName)  

'用“替換內(nèi)容”替換文件中所有“查找內(nèi)容”  
dFileContents = replace(FileContents, Find, ReplaceWith, 1, -1, 1)  

'比較源文件和替換后的文件  
if dFileContents <> FileContents Then  
'保存替換后的文件  
WriteFile FileName, dFileContents  

Wscript.Echo "Replace done."  
If Len(ReplaceWith) <> Len(Find) Then  
'計算替換總數(shù)  
Wscript.Echo _  
( (Len(dFileContents) - Len(FileContents)) / (Len(ReplaceWith)-Len(Find)) ) & _  
" replacements."  
End If  
Else  
Wscript.Echo "Searched string Not In the source file"  
End If  

'讀取文件  
function GetFile(FileName)  
If FileName<>"" Then  
Dim FS, FileStream  
Set FS = CreateObject("Scripting.FileSystemObject")  
on error resume Next  
Set FileStream = FS.OpenTextFile(FileName)  
GetFile = FileStream.ReadAll  
End If  
End Function  

'寫文件  
function WriteFile(FileName, Contents)  
Dim OutStream, FS  

on error resume Next  
Set FS = CreateObject("Scripting.FileSystemObject")  
Set OutStream = FS.OpenTextFile(FileName, 2, True)  
OutStream.Write Contents  
End Function

相關(guān)文章

最新評論

景东| 庆云县| 铜鼓县| 集贤县| 额尔古纳市| 山东省| 商水县| 唐河县| 远安县| 夏津县| 彭泽县| 彭州市| 新昌县| 阿图什市| 陵川县| 慈利县| 巴彦淖尔市| 淮阳县| 宁晋县| 张家界市| 苏尼特左旗| 奉化市| 博湖县| 竹山县| 米泉市| 明水县| 桃江县| 会宁县| 新干县| 黔南| 五大连池市| 九寨沟县| 涞源县| 泉州市| 昭通市| 连南| 濮阳县| 海南省| 安宁市| 兴安盟| 鹤岗市|