<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; VBScript: Поиск и копирование файла]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=5407</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=5407&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «VBScript: Поиск и копирование файла».]]></description>
		<lastBuildDate>Thu, 20 Jan 2011 14:25:07 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: VBScript: Поиск и копирование файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=44116#p44116</link>
			<description><![CDATA[<p><span style="color: green">Тема, имеющая в заголовке слова «Помогите!!» сразу попадает под <a href="http://forum.script-coding.com/rules.html">Правила форума</a>. Убрал.</span></p>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Thu, 20 Jan 2011 14:25:07 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=44116#p44116</guid>
		</item>
		<item>
			<title><![CDATA[VBScript: Поиск и копирование файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=44114#p44114</link>
			<description><![CDATA[<p>Помогите редактировать скрипт. Нужно его дописать так, чтоб если он нашел файл то копировал в папку &quot;c:\faily&quot;. Ищет он все хорошо, только вот я сколько пытался не смог заставить его копировать найденный файл.:(</p><p> </p><div class="codebox"><pre><code>Option Explicit
&#039;Dim objArgs
Dim strFileName

&#039;If Not WScript.Arguments.Named.Exists(&quot;FileName&quot;) Then
&#039;    WScript.Echo &quot;Using: &quot; &amp; WScript.ScriptName &amp; &quot; /FileName:&lt;file for find&gt;&quot;
&#039;    WScript.Quit 1
&#039;End If

&#039;strFileName = WScript.Arguments.Named.Item(&quot;FileName&quot;)

strFileName = &quot;primer.txt&quot; &#039; — имя файла для поиска писать здесь
Dim objFSO
Dim objDrive
ReDim arrPaths(0)
Dim i
Set objFSO = WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)
arrPaths(LBound(arrPaths)) = False
For Each objDrive In objFSO.Drives
If objDrive.DriveType = 2 Then
If objDrive.IsReady Then
FindInSubFolders objDrive.RootFolder, strFileName
End If
End If
Next
If arrPaths(LBound(arrPaths)) Then
WScript.Echo &quot;Found paths for file [&quot; &amp; strFileName &amp; &quot;]:&quot;
For i = LBound(arrPaths) + 1 To UBound(arrPaths)
WScript.Echo arrPaths(i)
Next
Else
WScript.Echo &quot;Not found paths for file [&quot; &amp; strFileName &amp; &quot;].&quot;
End If
Set objFSO = Nothing
WScript.Quit 0

Sub FindInSubFolders(objFolderForFind, strFileName)
Dim objFolder
&#039;WScript.Echo objFolderForFind.Path
If objFSO.FileExists(objFSO.BuildPath(objFolderForFind, strFileName)) Then
ReDim Preserve arrPaths(Ubound(arrPaths) + 1)
arrPaths(LBound(arrPaths)) = True
arrPaths(UBound(arrPaths)) = objFSO.BuildPath(objFolderForFind, strFileName)
&#039;WScript.Echo &quot;Found file [&quot; &amp; strFileName &amp; &quot;] on folder [&quot; &amp; objFolderForFind.Path &amp; &quot;]&quot;
End If
On Error Resume Next
For Each objFolder In objFolderForFind.SubFolders
If Err.Number = 0 Then
FindInSubFolders objFolder, strFileName
Else
Err.Clear
&#039;WScript.Echo &quot;Can&#039;t enumerate subfolders for folder [&quot; &amp; objFolderForFind.Path &amp; &quot;]&quot;
End If
Next
On Error Goto 0
End Sub</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (SNR93)]]></author>
			<pubDate>Thu, 20 Jan 2011 14:08:56 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=44114#p44114</guid>
		</item>
	</channel>
</rss>
