Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Компьютеры » Программы » Total Commander (часть 2)

Модерирует : gyra, Maz

Widok (21-06-2006 15:11): лимит страниц- продолжаем здесь.  Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

   

Yuk



Advanced Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору

'  File:         ReplaceInFiles.vbs
'  Description:  Search and replace of text
'                in selected files
'  Installation: Create a button on a TC bar
'                Command: "disk:\path\ReplaceInFiles.vbs"
'                Parameters: "%L" (exactly in "")
'  Copyright:    (c) 2006, Volniy (mod by Yuk)
 
Option Explicit
 
Dim FSO, Find_String, Replace_String, F, Buffer, ListFile, re
Const ForReading = 1, ForWriting = 2
 
Set FSO = CreateObject("Scripting.FileSystemObject")
Set re = New RegExp
 
Find_String = InputBox("Enter search string", "Search and Replace")
If Len(Find_String) = 0 Then
   MsgBox "Search string was not set!", vbExclamation, "Search and Replace"
   WScript.Quit()
End If
 
Replace_String = InputBox("Enter replace string", "Search and Replace")
 
Set ListFile = FSO.OpenTextFile(WScript.Arguments(0), 1)
Do While Not ListFile.AtEndOfStream
   Call DoItForThisFile(ListFile.ReadLine)
Loop
ListFile.Close
Set ListFile = Nothing
Set F = Nothing
Set FSO = Nothing
 
MsgBox "Replace done!", vbInformation, "Search and Replace"
WScript.Quit
 
Sub DoItForThisFile(FilePath)
   Set F = FSO.OpenTextFile(FilePath, ForReading)
   Buffer = F.ReadAll
   F.Close
 
 
    re.Pattern = Find_String
    re.Global = True
    re.IgnoreCase = True
    re.MultiLine = True  
 
   Buffer = re.Replace(CStr(Buffer), Replace_String)
   FSO.CopyFile FilePath, FilePath & ".bak"
 
   Set F = FSO.OpenTextFile(FilePath, ForWriting)
   F.Write Buffer
   F.Close
End Sub

Всего записей: 1182 | Зарегистр. 02-07-2001 | Отправлено: 23:50 31-05-2006
   

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Компьютеры » Программы » Total Commander (часть 2)
Widok (21-06-2006 15:11): лимит страниц- продолжаем здесь.


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru