欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

'新建一個(gè)Replace.vbs腳本,腳本內(nèi)容如下,程序運(yùn)行時(shí)輸入三個(gè)參數(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  
'計(jì)算替換總數(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)文章

最新評論