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: Автозамена части строки в XML на имя родительского каталога 
Author Message
Lev



PostPosted: Tue Apr 12, 2011 18:32    Post subject: Reply with quote

Попробуй
Code:
'replaceinfiles.vbs
'Lev

'Параметры вызова
'wscript.exe "Диск:\Путь к скрипту\replaceinfiles.vbs"
'%P%S

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

Set args = WScript.Arguments

texttoreplace="просто_папка"

For Each f In args
  If fso.GetFile(f).Size<>0 Then
    Set ts = fso.GetFile(f).OpenAsTextStream(1, 0)
    st=ts.ReadAll
    ts.Close
    counter = 0
    If InStr(st, texttoreplace) Then
      counter = counter + 1
      '---бакап файла на всякий случай, закомментируй если не нужен
      fso.CopyFile f, fso.GetAbsolutePathName(f) & ".bak"
     
      Set ts = fso.GetFile(f).OpenAsTextStream(2, 0)
      ts.Write(Replace(st, texttoreplace, fso.GetFile(f).ParentFolder.Name))

      ts.Close
    End If
   End If
Next
Msgbox "Готово, кол-во найденных файлов - " & counter


Last edited by Lev on Tue Apr 19, 2011 15:55; edited 2 times in total
View user's profile Send private message


Powered by phpBB © 2001, 2005 phpBB Group