Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Ветеран


Сообщения: 27449
Благодарности: 8088

Профиль | Отправить PM | Цитировать


Пример…
Код: Выделить весь код
Option Explicit

Dim strSourceFile
Dim strDestFolder
Dim strFindString
Dim strContent


strSourceFile = "c:\Source\0001.txt"
strDestFolder = "c:\Destination"
strFindString = "что ищем"

With WScript.CreateObject("Scripting.FileSystemObject")
	If .FileExists(strSourceFile) Then
		If .FolderExists(strDestFolder) Then
			With .GetFile(strSourceFile)
				With .OpenAsTextStream()
					strContent = .ReadAll()
					.Close
				End With
				
				If InStr(strContent, strFindString) > 0 Then
					.Move strDestFolder & "\"
				End If
			End With
		Else
			WScript.Echo "Destination folder [" & strDestFolder & "] not found"
		End If
	Else
		WScript.Echo "Source file [" & strSourceFile & "] not found"
	End If
End With

WScript.Quit 0

При существовании в папке назначения одноимённого файла попытка перемещения оригинального файла завершится с ошибкой времени исполнения.
Это сообщение посчитали полезным следующие участники:

Отправлено: 05:38, 28-03-2012 | #2