<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBS или JS:Сортировка файлов по подпапкам]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6743&amp;type=atom" />
	<updated>2012-02-03T08:12:18Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=6743</id>
		<entry>
			<title type="html"><![CDATA[Re: VBS или JS:Сортировка файлов по подпапкам]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=56351#p56351" />
			<content type="html"><![CDATA[<p>Все отлично работает! Большое спасибо!</p>]]></content>
			<author>
				<name><![CDATA[griha09]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27540</uri>
			</author>
			<updated>2012-02-03T08:12:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=56351#p56351</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS или JS:Сортировка файлов по подпапкам]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=56122#p56122" />
			<content type="html"><![CDATA[<p>Если не особо вдаваться в вопросы отказоустойчивости и оптимизации, то наверное как то так.<br /></p><div class="codebox"><pre><code>
Option Explicit
Const SrcFolderPath = &quot;ИсхПапка&quot;
Const ResFolderPath = &quot;РезПапка&quot;

Dim FileSystemObject, TextStream, Folder, SubFolder, File, FilePath
Set FileSystemObject = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set TextStream = FileSystemObject.OpenTextFile(&quot;log.txt&quot;,8,True)

TextStream.WriteLine &quot;----- &quot; &amp; Now &amp; &quot; -----&quot;

RecursiveFolderScan SrcFolderPath

MsgBox &quot;Обработка завершена&quot;,vbInformation

&#039;Создаём процедуру рекурсивного обхода каталога
Sub RecursiveFolderScan(FolderPath)
    &#039;Получаем объектную модель текущего каталога
    Set Folder = FileSystemObject.GetFolder(FolderPath)
    
    &#039;Перебираем все файлы в текущем каталоге
    For Each File in Folder.Files
        &#039;Проверяем существование аналогичного файла в результирующем каталоге
        FilePath = FileSystemObject.BuildPath(ResFolderPath,File.Name)
        If FileSystemObject.FileExists(FilePath) Then
            &#039;Если он существует, то производим замену
            FileSystemObject.CopyFile FilePath, FileSystemObject.BuildPath(Folder.Path,&quot;\&quot;)
            AppendToLog &quot;файл &quot;&quot;&quot; &amp; File.Name &amp; &quot;&quot;&quot; скопирован в &quot;&quot;&quot; &amp; Folder.Path &amp; &quot;&quot;&quot;.&quot;
        End if
    Next
    
    &#039;Перебираем все подкаталоги в каталоге
    For Each SubFolder in Folder.SubFolders
        RecursiveFolderScan(SubFolder.Path)
    Next
End Sub

Sub AppendToLog(Text)
    TextStream.WriteLine Time &amp; &quot;:&quot; &amp; Text
End Sub</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Xameleon]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=8836</uri>
			</author>
			<updated>2012-01-30T08:14:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=56122#p56122</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS или JS:Сортировка файлов по подпапкам]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=56099#p56099" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>papka=&quot;D:\RezPapka\&quot;  &#039;откуда копируем
papka2=&quot;D:\IshPapka\&quot; &#039;куда копируем
Set oShell = WScript.CreateObject (&quot;WScript.Shell&quot;)
Set objRegExp = CreateObject(&quot;VBScript.RegExp&quot;)
objRegExp.IgnoreCase = True
Set FSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set Folder = FSO.GetFolder(papka)
Set Folder2 = FSO.GetFolder(papka2)

For Each File In Folder.Files
Set File = FSO.GetFile(File)

For Each File2 In Folder2.Files
Set File2 = FSO.GetFile(File)

If File.Name=File2.Name Then    
File.Move Folder2

End If

Next


Next</code></pre></div>]]></content>
			<author>
				<name><![CDATA[griha09]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27540</uri>
			</author>
			<updated>2012-01-29T12:24:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=56099#p56099</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS или JS:Сортировка файлов по подпапкам]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=56087#p56087" />
			<content type="html"><![CDATA[<p>А можно взглянуть на наработки, в которых что то не получилось ?</p>]]></content>
			<author>
				<name><![CDATA[Xameleon]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=8836</uri>
			</author>
			<updated>2012-01-28T19:41:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=56087#p56087</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBS или JS:Сортировка файлов по подпапкам]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=56086#p56086" />
			<content type="html"><![CDATA[<p>Я иногда обрабатываю фотки автоматом в Фотошопе. Он обрабатывает сразу папку с подпапками, а результат кидает в одну папку. Вот пытался сделать скрипт VBS сортирующий файл обратно в подпапки да что-то не получается. Т.е. есть РезПапка с результатами и ИсхПапка с подпапками, надо пройтись по подпапкам если там есть файл с таким именем, то файл из РезПапки перенести в эту подпапку. <br />Кто может сделать на VBS или JS все равно?</p>]]></content>
			<author>
				<name><![CDATA[griha09]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27540</uri>
			</author>
			<updated>2012-01-28T19:32:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=56086#p56086</id>
		</entry>
</feed>
