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

批量文件查找替換功能的vbs腳本

 更新時間:2008年05月06日 22:25:24   作者:  
用vbs實(shí)現(xiàn)的批量文件的替換
'============================================
'code by lcx 修改網(wǎng)上原有的一個小程序,不知作者,那個程序沒有對目錄實(shí)現(xiàn)遞歸查找
'將本程序放在你要查找的目錄下,或把查找的目錄拖到此腳本上,估計還有bug
'=======================================================================================
On Error Resume next
Do Until False
        Findstr=InputBox("請輸入你要查找的字符(串):", "請輸入")
        If Findstr <> "" Then
                Exit do
        End If
Loop

repwith=InputBox("請輸入你要替換的字符(串):,如果留空則只為查找", "請輸入")


If Wscript.Arguments.Count <> 0 Then
        For i=0 To WScript.Arguments.Count-1
                folderpath=WScript.Arguments(i)
                find(folderpath)
        Next
Else
        '處理當(dāng)前目錄
        Set objShell = CreateObject("WScript.Shell")
        folderpath=objShell.CurrentDirectory
        find(folderpath)
End If

'替換主程序
Sub find(path)
        set fso=CreateObject("Scripting.FileSystemObject")
        set current=fso.GetFolder(path)
        For Each file In current.Files

                        set fsofile=fso.OpenTextFile(file, 1, true)
       On Error Resume next
                        tempstr=fsofile.Readall

       If InstrRev(tempstr,Findstr, -1, 0)<>0 And repwith = "" Then 
       with Fso.opentextfile(left(Wscript.ScriptFullName,len(Wscript.ScriptFullName)-len(Wscript.ScriptName))&"\re.txt",8,true)
                        .writeline file
       .close
       end with
       End If

       If repwith <> "" Then
       tempstr=replace(tempstr, Findstr, repwith)
       set fsofile1=fso.OpenTextFile(file, 2, true)
                        fsofile1.WriteLine tempstr
       fsofile.close
       End if

                       
        Next

   for each folder in current.subfolders 
   Call find(folder.path)
   next

set fso=nothing
End Sub

msgbox "OK,查找的文件名保存在re.txt"

相關(guān)文章

最新評論