<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; HTA: Копирование новых файлов]]></title>
		<link>http://forum.script-coding.com/viewtopic.php?id=7791</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=7791&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «HTA: Копирование новых файлов».]]></description>
		<lastBuildDate>Thu, 21 Jan 2021 19:42:24 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: HTA: Копирование новых файлов]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=145189#p145189</link>
			<description><![CDATA[<p>По поводу скрипта <a href="http://forum.script-coding.com/viewtopic.php?pid=103470#p103470">синхронизирующего содержимое двух каталогов</a>. По какой причине исключение каталога из обработки не происходит, если в именах присутствует кириллица?<br /></p><div class="codebox"><pre><code>ExclusionList(2)= .BuildPath(fromDir, &quot;Избранное&quot;)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (DD)]]></author>
			<pubDate>Thu, 21 Jan 2021 19:42:24 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=145189#p145189</guid>
		</item>
		<item>
			<title><![CDATA[Re: HTA: Копирование новых файлов]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=103593#p103593</link>
			<description><![CDATA[<p><strong>DD</strong><br />Можно попробовать ещё один метод, но для этого придётся отключать в свойствах корзины подтверждение на удаление.<br />Действуем по той же схеме.<br /></p><div class="codebox"><pre><code>Set Desc = CreateObject(&quot;Shell.Application&quot;).Namespace(0)</code></pre></div><p>+<br /></p><div class="codebox"><pre><code>                Desc.ParseName(targetFile).InvokeVerb(&quot;delete&quot;)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Flasher)]]></author>
			<pubDate>Mon, 09 May 2016 18:19:23 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=103593#p103593</guid>
		</item>
		<item>
			<title><![CDATA[Re: HTA: Копирование новых файлов]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=103558#p103558</link>
			<description><![CDATA[<p>Для корзины на C: зарезервировано 700 MB, а файлы на удаление весят много меньше и их незначительное количество, так что процесс wscript.exe практически сразу завершается.</p>]]></description>
			<author><![CDATA[null@example.com (DD)]]></author>
			<pubDate>Mon, 09 May 2016 11:42:20 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=103558#p103558</guid>
		</item>
		<item>
			<title><![CDATA[Re: HTA: Копирование новых файлов]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=103541#p103541</link>
			<description><![CDATA[<p>Есть вероятность, что они там не сразу появляются после отработки скрипта. Дождитесь.<br />И, разумеется, для диска (в данном случае C:) в настройках корзины должен быть установлен годный максимальный размер.</p>]]></description>
			<author><![CDATA[null@example.com (Flasher)]]></author>
			<pubDate>Mon, 09 May 2016 01:52:46 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=103541#p103541</guid>
		</item>
		<item>
			<title><![CDATA[Re: HTA: Копирование новых файлов]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=103540#p103540</link>
			<description><![CDATA[<p>А всё-таки, перемещения в Корзину не происходит, хотя файлы на перемещение фиксируются. Просьба взглянуть, всё ли верно подставил:</p>]]></description>
			<author><![CDATA[null@example.com (DD)]]></author>
			<pubDate>Mon, 09 May 2016 01:32:14 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=103540#p103540</guid>
		</item>
		<item>
			<title><![CDATA[Re: HTA: Копирование новых файлов]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=103539#p103539</link>
			<description><![CDATA[<p>Большое спасибо!</p>]]></description>
			<author><![CDATA[null@example.com (DD)]]></author>
			<pubDate>Mon, 09 May 2016 01:12:31 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=103539#p103539</guid>
		</item>
		<item>
			<title><![CDATA[Re: HTA: Копирование новых файлов]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=103538#p103538</link>
			<description><![CDATA[<p>Можно. Где-нибудь выше Call FoldersSynch(fromDir, toDir) вставьте:<br /></p><div class="codebox"><pre><code>Set RecycleBin = CreateObject(&quot;Shell.Application&quot;).Namespace(&amp;Ha)</code></pre></div><p>А вместо<br /></p><div class="codebox"><pre><code>                targetFile.Delete(True)</code></pre></div><p>&gt;&gt;<br /></p><div class="codebox"><pre><code>                RecycleBin.MoveHere(targetFile)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Flasher)]]></author>
			<pubDate>Mon, 09 May 2016 00:22:18 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=103538#p103538</guid>
		</item>
		<item>
			<title><![CDATA[Re: HTA: Копирование новых файлов]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=103520#p103520</link>
			<description><![CDATA[<p>Вот спасибо! Ещё по коду вопрос, если позволите: дано ли настроить его на удаление &quot;лишних файлов&quot; в корзину, а не мимо неё?</p>]]></description>
			<author><![CDATA[null@example.com (DD)]]></author>
			<pubDate>Sun, 08 May 2016 22:56:23 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=103520#p103520</guid>
		</item>
		<item>
			<title><![CDATA[Re: HTA: Копирование новых файлов]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=103517#p103517</link>
			<description><![CDATA[<p>Лишнюю первую строку посчитал. Ошибся. Исправил номера.<br />А вообще при ошибках принято писать дословные данные: описание и номер строки.</p>]]></description>
			<author><![CDATA[null@example.com (Flasher)]]></author>
			<pubDate>Sun, 08 May 2016 20:28:30 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=103517#p103517</guid>
		</item>
		<item>
			<title><![CDATA[Re: HTA: Копирование новых файлов]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=103511#p103511</link>
			<description><![CDATA[<p>Все равно пишет, что требуется объект. Прикрепил тему, откуда брал скрипт.</p>]]></description>
			<author><![CDATA[null@example.com (DD)]]></author>
			<pubDate>Sun, 08 May 2016 16:40:27 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=103511#p103511</guid>
		</item>
		<item>
			<title><![CDATA[Re: HTA: Копирование новых файлов]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=103482#p103482</link>
			<description><![CDATA[<p>И 113-ой ещё.&nbsp; Это не проблема языка, это проблема кода (уж не знаю, насколько исходного).</p><p>P.S.: У нас точки принято ставить.</p>]]></description>
			<author><![CDATA[null@example.com (Flasher)]]></author>
			<pubDate>Sat, 07 May 2016 23:47:53 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=103482#p103482</guid>
		</item>
		<item>
			<title><![CDATA[Re: HTA: Копирование новых файлов]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=103479#p103479</link>
			<description><![CDATA[<p>Добавляю — и в другом месте возникает та же ошибка)) Наугад и туда добавляю — так и снова ошибка, об отсутствующем объекте)) Неужели под VBS старые скрипты как и в AHK не работают))</p>]]></description>
			<author><![CDATA[null@example.com (DD)]]></author>
			<pubDate>Sat, 07 May 2016 23:27:35 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=103479#p103479</guid>
		</item>
		<item>
			<title><![CDATA[Re: HTA: Копирование новых файлов]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=103473#p103473</link>
			<description><![CDATA[<p>87 строкой добавьте.</p>]]></description>
			<author><![CDATA[null@example.com (Flasher)]]></author>
			<pubDate>Sat, 07 May 2016 22:58:12 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=103473#p103473</guid>
		</item>
		<item>
			<title><![CDATA[Re: HTA: Копирование новых файлов]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=103470#p103470</link>
			<description><![CDATA[<p>Приводимый скрипт из одной из старых удаленных тем. Запускаю его как есть, но по поводу &quot;Next&quot; ошибка —<br /></p><div class="codebox"><pre><code>
&#039;Синхронизация содержимого двух каталогов

&#039;**********************************************
&#039;Исходный каталог
fromDir = &quot;C:\4444444&quot;

&#039;Приемный каталог
&#039;toDir = &quot;\\TargetServer\d$\UserData&quot;
toDir = &quot;C:\5555&quot;

&#039;Сравнивать время изменения файлов с точностью до
&#039; 2 секунд - при переносе файлов с NTFS на FAT
&#039; 0 секунд - в остальных случаях
TimeDifference = 0

Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)

&#039;Подкаталоги ИСХОДНОГО каталога исключаемые из обработки
Dim ExclusionList(2)
With fso
    ExclusionList(0)= .BuildPath(fromDir, &quot;_gsdata_&quot;)
    ExclusionList(1)= .BuildPath(fromDir, &quot;index&quot;)
    ExclusionList(2)= .BuildPath(fromDir, &quot;Temp\temporaryFolder&quot;)
End With
&#039;**********************************************

replaceSize = 0
copySize = 0
deleteSize = 0
noChangeSize = 0

replaceCount = 0
deleteCount = 0
noChangeCount = 0
copyCount = 0

ExclusionListCount = 0

Call CheckFolder(fromDir)

Start = Timer

Call FoldersSynch(fromDir, toDir)

Finish = Timer

delim = vbTab &amp; &quot;...   :   &quot;

Dim message(11)
message(0) = &quot; Файлов без изменений&quot; &amp; delim &amp; noChangeCount &amp; vbTab &amp; &quot;[&quot; &amp; Conversion(noChangeSize) &amp; &quot;]&quot;
message(1) = String(33, &quot;-&quot;)
message(2) = &quot; Удалено лишних&quot; &amp; vbTab &amp; delim &amp; deleteCount &amp; vbTab &amp; &quot;[&quot; &amp; Conversion(deleteSize) &amp; &quot;]&quot;
message(3) = &quot; Заменено существующих&quot; &amp; delim &amp; replaceCount &amp; vbTab &amp; &quot;[&quot; &amp; Conversion(replaceSize) &amp; &quot;]&quot;
message(4) = &quot; Добавлено новых&quot; &amp; vbTab &amp; delim &amp; copyCount &amp; vbTab &amp; &quot;[&quot; &amp; Conversion(copySize) &amp; &quot;]&quot;
message(5) = String(33, &quot;-&quot;)
message(6) = &quot; Исключено каталогов&quot; &amp; delim &amp; ExclusionListCount
message(7) = &quot;&quot;
message(8) = String(33, &quot;-&quot;)
message(9) = &quot; РАЗМЕР ОБНОВЛЕНИЙ&quot; &amp; delim &amp; Conversion(replaceSize + copySize)
message(10) = &quot;&quot;
message(11) = &quot; Время выполнения&quot; &amp; delim &amp; (Finish - Start) &amp; &quot;   сек.&quot;

MsgBox Join(message, vbCrLf), vbInformation, &quot;Сообщение синхронизатора&quot;

Sub CheckFolder(FolderName)
If Not fso.FolderExists(FolderName) Then
    MsgBox &quot;Нет доступа к ресурсу &#039;&#039;&quot; &amp; FolderName &amp; &quot;&#039;&#039;&quot;, vbCritical, &quot;Сообщение синхронизатора&quot;
    WScript.Quit()
End If
End Sub

Sub FoldersSynch(source, target)
Dim sourceDir, sourceFile, targetDir, targetFile, sourceSubDir, targetSubDir
    Set sourceDir = fso.GetFolder(source)
    If Not FolderExcluded(source, ExclusionList) Then
        SmartCreateFolder target
        Set targetDir = fso.GetFolder(target)
        If targetDir.Attributes &lt;&gt; sourceDir.Attributes Then
            targetDir.Attributes = sourceDir.Attributes
        End If
        For Each targetFile in targetDir.Files
            If Not fso.FileExists(fso.BuildPath(source, targetFile.Name)) Then
                deleteSize = deleteSize + targetFile.Size
                targetFile.Delete(True)
                deleteCount = deleteCount + 1
            End If
        For Each sourceFile in sourceDir.Files
            If Not fso.FileExists(fso.BuildPath(target, sourceFile.Name)) Then
                sourceFile.Copy fso.BuildPath(target, sourceFile.Name)
                copySize = copySize + sourceFile.Size
                copyCount = copyCount + 1
            Else
                Set targetFile = fso.GetFile(fso.BuildPath(target, sourceFile.Name))
                If Abs(DateDiff(&quot;s&quot;, sourceFile.DateLastModified, targetFile.DateLastModified)) &gt; TimeDifference Then
                    If targetFile.Attributes And 1 Then
                        targetFile.Attributes = targetFile.Attributes - 1
                    End If
                    sourceFile.Copy targetFile, True
                    replaceSize = replaceSize + sourceFile.Size
                    replaceCount = replaceCount + 1
                Else
                    If targetFile.Attributes &lt;&gt; sourceFile.Attributes Then
                        targetFile.Attributes = sourceFile.Attributes
                    End If
                    noChangeSize = noChangeSize + sourceFile.Size
                    noChangeCount = noChangeCount + 1
                End If
            End If
        Next &#039;sourceFile
        For Each sourceSubDir in sourceDir.SubFolders
            FoldersSynch sourceSubDir.Path, fso.BuildPath(target, sourceSubDir.Name)
        For Each targetSubDir in targetDir.SubFolders
            If Not fso.FolderExists(fso.BuildPath(source, targetSubDir.Name)) Then
                ExtraCount targetSubDir.Path, deleteCount
                deleteSize = deleteSize + targetSubDir.Size
                targetSubDir.Delete(True)
            End If
        Next &#039;targetSubDir
    Else
        ExclusionListCount = ExclusionListCount + 1
    End If
End Sub

Sub SmartCreateFolder(strFolder)
    If fso.FolderExists(strFolder) Then
        Exit Sub
    Else
        SmartCreateFolder(fso.GetParentFolderName(strFolder))
    End If
    fso.CreateFolder(strFolder)
End Sub

Function FolderExcluded(qFolder, qArray)
Dim q, LenFolder, LenArray, tmpStr
For q = 0 To UBound(qArray)
    If LCase(qArray(q)) = LCase(qFolder) Then
        FolderExcluded = True
        Exit Function
    Else
        LenFolder = Len(qFolder)
        LenArray = Len(qArray(q))
        If LenFolder &gt; LenArray Then
            tmpStr = Mid(qFolder, 1, LenArray)
            If LCase(qArray(q)) = LCase(tmpStr) _
            And Mid(qFolder, Len(tmpStr)+1, 1) = &quot;\&quot; Then
                FolderExcluded = True
                Exit Function
            End If
        End if
    End If
Next &#039;q
    FolderExcluded = False
End Function

Function ExtraCount(ExtraFolderName, Counter)
Dim ExtraFolder, ExtraSubFolder, ExtraFile
    Set ExtraFolder = fso.GetFolder(ExtraFolderName)
&#039;Подсчет числа файлов в корневом каталоге
    Counter = Counter + ExtraFolder.Files.Count
&#039;Подсчет числа файлов в подкаталогах
    For Each ExtraSubFolder in ExtraFolder.SubFolders
        ExtraCount ExtraSubFolder.Path, Counter
    Next &#039;ExtraSubFolder
End Function

Function Conversion(ByteSize)
    if FormatNumber(ByteSize, 0) &lt; 1024 Then
        Conversion = FormatNumber(ByteSize, 0) &amp; &quot;   байт&quot;
    ElseIf FormatNumber(ByteSize/1024, 2) &lt; 1024 Then
        Conversion = FormatNumber(ByteSize/1024, 2) &amp; &quot;   Кбайт&quot;
    Else
        Conversion = FormatNumber(ByteSize/1024/1024, 2) &amp; &quot;   Мбайт&quot;
    End If
End Function
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (DD)]]></author>
			<pubDate>Sat, 07 May 2016 22:48:47 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=103470#p103470</guid>
		</item>
		<item>
			<title><![CDATA[Re: HTA: Копирование новых файлов]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=103469#p103469</link>
			<description><![CDATA[<p>Вопрос по VBS-скрипту из первого сообщения: каждый ли раз им производится перезапись всех файлов, или он сравнивает даты? Возможен ли скрипт, который бы в точности воспроизводил состояние исходной папки, без повторной полной перезаписи всех файлов в приёмную?</p>]]></description>
			<author><![CDATA[null@example.com (DD)]]></author>
			<pubDate>Sat, 07 May 2016 22:47:23 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=103469#p103469</guid>
		</item>
	</channel>
</rss>
