Total Commander Forum Index Total Commander
Форум поддержки пользователей Total Commander
Сайты: Все о Total Commander | Totalcmd.net | Ghisler.com | RU.TCKB
 
 RulesRules   SearchSearch   FAQFAQ   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Single Post  Topic: Windows Script Host 
Author Message
iG0R



PostPosted: Tue Mar 26, 2013 20:13    Post subject: Reply with quote

Batya
Спасибо за ответ, но этот скрипт
по сути ничем не отличается от ReplaceInFiles.vbs со страницы №4
Code:

'  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


Который может искать по Esc-последовательности, но не может заменять. Sad
View user's profile Send private message


Powered by phpBB © 2001, 2005 phpBB Group