Lev

|
Posted: Tue Apr 12, 2011 18:32 Post subject: |
|
|
Попробуй
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 |
|