最新国产好看的视频,伊人天堂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)文章

最新評論

甘孜县| 贵港市| 保山市| 林西县| 九龙城区| 宜都市| 惠水县| 海南省| 田阳县| 肥乡县| 呼图壁县| 乌兰浩特市| 措美县| 无极县| 金阳县| 西贡区| 松江区| 潮州市| 临武县| 绥棱县| 新龙县| 如东县| 都安| 桃园市| 马鞍山市| 东海县| 达日县| 吉首市| 无棣县| 濮阳市| 来宾市| 石屏县| 泸西县| 买车| 扶风县| 通城县| 九寨沟县| 茶陵县| 页游| 吉林省| 巨野县|