<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; CMD/BAT: перенос файлов из каталога и его подкаталогов с сортировкой]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=11359</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11359&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «CMD/BAT: перенос файлов из каталога и его подкаталогов с сортировкой».]]></description>
		<lastBuildDate>Mon, 29 Feb 2016 09:33:58 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: CMD/BAT: перенос файлов из каталога и его подкаталогов с сортировкой]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=101494#p101494</link>
			<description><![CDATA[<p><strong>Abashin</strong><br />Ага, точно. Добавил важную строку.</p>]]></description>
			<author><![CDATA[null@example.com (Flasher)]]></author>
			<pubDate>Mon, 29 Feb 2016 09:33:58 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=101494#p101494</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: перенос файлов из каталога и его подкаталогов с сортировкой]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=101493#p101493</link>
			<description><![CDATA[<p><strong>Flasher</strong><br />Где-то в логике скрипта (первого и второго варианта) серьёзная ошибка.<br />Скрипт завершает работу перенеся не все файлы соответствующие заданным шаблонам. Если повторно запустить скрипт пропущенные файлы переносятся. Все или требуется третий и четвертый запуск не установлено пока. В модельной ситуации (<a href="https://drive.google.com/file/d/0B_3VWntbZPsmekZIRUlLR2VITG8/view?usp=sharing">https://drive.google.com/file/d/0B_3VWn … sp=sharing</a>, первый вариант пропускает 6 файлов, второй 1 файл. Всегда одни и те же файлы.</p>]]></description>
			<author><![CDATA[null@example.com (Abashin)]]></author>
			<pubDate>Mon, 29 Feb 2016 06:21:44 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=101493#p101493</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: перенос файлов из каталога и его подкаталогов с сортировкой]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=101473#p101473</link>
			<description><![CDATA[<p><strong>Abashin</strong><br /><a href="http://forum.script-coding.com/viewtopic.php?id=10551">Не нужно цитировать посты с кодами</a>, достаточно написать про первый и второй вариант.<br />Первый поправил. Второй проверил на Win7 x86, никаких проблем. Возможно, фильтрация указана неверно.<br />Внёс мелкую коррекцию, чтобы файлы с односимвольным базовым именем тоже переносились.</p><p>Что касаемо флагов Filter, то список <a href="https://msdn.microsoft.com/ru-ru/library/windows/desktop/bb762539(v=vs.85).aspx">тут</a>. В vbs вместо 0x пишется &amp;H либо числами, <a href="http://forum.script-coding.com/viewtopic.php?pid=101320#p101320">как у меня</a> (как правило этих флагов достаточно).</p>]]></description>
			<author><![CDATA[null@example.com (Flasher)]]></author>
			<pubDate>Sun, 28 Feb 2016 09:09:01 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=101473#p101473</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: перенос файлов из каталога и его подкаталогов с сортировкой]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=101470#p101470</link>
			<description><![CDATA[<div class="quotebox"><cite>Flasher пишет:</cite><blockquote><p>На русском <a href="http://script-coding.com/WSH/Shell.html#4.3.2.">у нас</a>. Хотя с полным перечнем лучше <a href="https://msdn.microsoft.com/ru-ru/library/windows/desktop/bb787866(v=vs.85).aspx">на msdn</a>.</p></blockquote></div><p>Спасибо!<br />Разобрался. Не смог только на msdn найти полный перечень параметров для Filter. А на вашем сайте перечислены только три варианта.</p><br /><div class="quotebox"><cite>Flasher пишет:</cite><blockquote><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Если подпапки первого уровня = расширения файлов, то лучше так:</div><div class="fancy_spoiler"><div class="codebox"><pre><code>IPath = &quot;T:\FOLDER-1&quot;
TPath = &quot;T:\FOLDER-2&quot;
Filt  = &quot;*.fil;*.txt;*.lst&quot;

Set Shell = CreateObject(&quot;Shell.Application&quot;)
Set FSO   = CreateObject(&quot;Scripting.FilesystemObject&quot;)
Set OutDisk = Shell.NameSpace(FSO.GetDriveName(TPath))
FFolder IPath

Sub FFolder(Folder)
  Set Items = Shell.NameSpace(Folder).Items
  Items.Filter 73920, Filt
  For Each F In Items
	Ext = FSO.GetExtensionName(F.Path)
    Set Elems = ShA.NameSpace(Folder).Items
    Elems.Filter 73920, Left(F.Name, 2) &amp; &quot;*.&quot; &amp; Ext
    Trg = FSO.BuildPath(TPath, UCase(Ext)) &amp; &quot;\&quot; &amp; UCase(Left(F.Name, 2))
    If Not FSO.FolderExists(Trg) Then OutDisk.NewFolder(Mid(Trg, 4))
    ShA.NameSpace(Trg).MoveHere Elems, 280
    Items.Filter 73920, Filt
  Next : Items.Filter 73888, &quot;*&quot;
  For Each F In Items : FFolder F.Path : Next
End Sub</code></pre></div></div></div><p>Этот вариант оказывается не работает.<br /><a href="https://drive.google.com/file/d/0B_3VWntbZPsmYUNfUkFKaTFVeG8/view?usp=sharing">https://drive.google.com/file/d/0B_3VWn … sp=sharing</a></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Если эти подпапки&nbsp; произвольно названные, то так:</div><div class="fancy_spoiler"><div class="codebox"><pre><code>IPath = &quot;T:\FOLDER-1&quot;
TPath = &quot;T:\FOLDER-2&quot;

Set ShA = CreateObject(&quot;Shell.Application&quot;)
Set Dic = CreateObject(&quot;Scripting.Dictionary&quot;)
Set FSO = CreateObject(&quot;Scripting.FilesystemObject&quot;)
Set OutDisk = ShA.NameSpace(FSO.GetDriveName(TPath))

&#039;** Тут прописываем соотв. пути и маски: ***
Dic.Add FSO.BuildPath(TPath, &quot;FIL&quot;), &quot;*.fil&quot;
Dic.Add FSO.BuildPath(TPath, &quot;TXT&quot;), &quot;*.txt&quot;
Dic.Add FSO.BuildPath(TPath, &quot;LST&quot;), &quot;*.lst&quot;
&#039;*******************************************
FFolder IPath

Function FFolder(Folder)
  Set Items = ShA.NameSpace(Folder).Items
  For Each TPath In Dic.Keys
    Filt = Dic.Item(TPath)
    Items.Filter 73920, Filt
    For Each F In Items
      Set Elems = ShA.NameSpace(Folder).Items
      Elems.Filter 73920, Left(F.Name, 2) &amp; Filt
      Trg = FSO.BuildPath(TPath, UCase(Left(F.Name, 2)))
      If Not FSO.FolderExists(Trg) Then OutDisk.NewFolder(Mid(Trg, 4))
      ShA.NameSpace(Trg).MoveHere Elems, 280
      Items.Filter 73920, Filt
    Next
  Next : Items.Filter 73888, &quot;*&quot;
  For Each F In Items : FFolder F.Path : Next
End Function</code></pre></div></div></div></blockquote></div><p>Этот вариант работает в WinXP нормально, а в Win7 только создаёт структуру папок в FOLDER-2 без переноса файлов (ограничения безопасности?).</p>]]></description>
			<author><![CDATA[null@example.com (Abashin)]]></author>
			<pubDate>Sun, 28 Feb 2016 06:17:22 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=101470#p101470</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: перенос файлов из каталога и его подкаталогов с сортировкой]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=101455#p101455</link>
			<description><![CDATA[<p><strong>Abashin</strong><br />На русском <a href="http://script-coding.com/WSH/Shell.html#4.3.2.">у нас</a>. Хотя с полным перечнем лучше <a href="https://msdn.microsoft.com/ru-ru/library/windows/desktop/bb787866(v=vs.85).aspx">на msdn</a>.</p>]]></description>
			<author><![CDATA[null@example.com (Flasher)]]></author>
			<pubDate>Sat, 27 Feb 2016 10:02:08 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=101455#p101455</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: перенос файлов из каталога и его подкаталогов с сортировкой]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=101454#p101454</link>
			<description><![CDATA[<div class="quotebox"><cite>Flasher пишет:</cite><blockquote><p>272 вместо 280.</p></blockquote></div><p>А какие бывают ещё варианты? Подскажите где прочитать об значениях этого параметра?</p>]]></description>
			<author><![CDATA[null@example.com (Abashin)]]></author>
			<pubDate>Sat, 27 Feb 2016 09:14:06 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=101454#p101454</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: перенос файлов из каталога и его подкаталогов с сортировкой]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=101452#p101452</link>
			<description><![CDATA[<p><strong>Abashin</strong><br />272 вместо 280. Но смысл? Ведь в разных каталогах могут оказаться одноимённые файлы, которые в итоге перезапишут друг друга, и файлов будет перенесено меньше положенного.<br />И, кстати, <em>копия</em> должна быть после базового имени, а не перед.</p>]]></description>
			<author><![CDATA[null@example.com (Flasher)]]></author>
			<pubDate>Sat, 27 Feb 2016 08:36:46 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=101452#p101452</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: перенос файлов из каталога и его подкаталогов с сортировкой]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=101450#p101450</link>
			<description><![CDATA[<p><strong>Flasher</strong><br />Еще вопрос. Что нужно изменить в скрипте, чтобы происходила перезапись существующих в конечной папке файлов, а не запись с новым именем: <strong>Копия filename.ext</strong>?</p>]]></description>
			<author><![CDATA[null@example.com (Abashin)]]></author>
			<pubDate>Sat, 27 Feb 2016 08:20:29 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=101450#p101450</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: перенос файлов из каталога и его подкаталогов с сортировкой]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=101447#p101447</link>
			<description><![CDATA[<p><strong>Abashin</strong><br />Пож-та. Во втором скрипте пару имён исправил.</p>]]></description>
			<author><![CDATA[null@example.com (Flasher)]]></author>
			<pubDate>Fri, 26 Feb 2016 11:59:10 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=101447#p101447</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: перенос файлов из каталога и его подкаталогов с сортировкой]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=101446#p101446</link>
			<description><![CDATA[<p><strong>Flasher</strong><br />Спасибо</p>]]></description>
			<author><![CDATA[null@example.com (Abashin)]]></author>
			<pubDate>Fri, 26 Feb 2016 11:43:33 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=101446#p101446</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: перенос файлов из каталога и его подкаталогов с сортировкой]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=101445#p101445</link>
			<description><![CDATA[<p><strong>Abashin</strong><br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Если подпапки первого уровня = расширения файлов, то лучше так:</div><div class="fancy_spoiler"><div class="codebox"><pre><code>IPath = &quot;T:\FOLDER-1&quot;
TPath = &quot;T:\FOLDER-2&quot;
Filt  = &quot;*.fil;*.txt;*.lst&quot;

Set Shell = CreateObject(&quot;Shell.Application&quot;)
Set FSO   = CreateObject(&quot;Scripting.FilesystemObject&quot;)
Set OutDisk = Shell.NameSpace(FSO.GetDriveName(TPath))
FFolder IPath

Sub FFolder(Folder)
  Set Items = Shell.NameSpace(Folder).Items
  Items.Filter 73920, Filt
  For Each F In Items
	Ext = FSO.GetExtensionName(F.Path)
    Set Elems = Shell.NameSpace(Folder).Items
    Elems.Filter 73920, Left(F.Name, 2) &amp; &quot;*.&quot; &amp; Ext
    Trg = FSO.BuildPath(TPath, UCase(Ext)) &amp; &quot;\&quot; &amp; UCase(Left(F.Name, 2))
    If Not FSO.FolderExists(Trg) Then OutDisk.NewFolder(Mid(Trg, 4))
    Shell.NameSpace(Trg).MoveHere Elems, 280
	Set Items = Shell.NameSpace(Folder).Items
    Items.Filter 73920, Filt
  Next : Items.Filter 73888, &quot;*&quot;
  For Each F In Items : FFolder F.Path : Next
End Sub</code></pre></div></div></div><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Если эти подпапки&nbsp; произвольно названные, то так:</div><div class="fancy_spoiler"><div class="codebox"><pre><code>IPath = &quot;T:\FOLDER-1&quot;
TPath = &quot;T:\FOLDER-2&quot;

Set ShA = CreateObject(&quot;Shell.Application&quot;)
Set Dic = CreateObject(&quot;Scripting.Dictionary&quot;)
Set FSO = CreateObject(&quot;Scripting.FilesystemObject&quot;)
Set OutDisk = ShA.NameSpace(FSO.GetDriveName(TPath))

&#039;** Тут прописываем соотв. пути и маски: ***
Dic.Add FSO.BuildPath(TPath, &quot;FIL&quot;), &quot;*.fil&quot;
Dic.Add FSO.BuildPath(TPath, &quot;TXT&quot;), &quot;*.txt&quot;
Dic.Add FSO.BuildPath(TPath, &quot;LST&quot;), &quot;*.lst&quot;
&#039;*******************************************
FFolder IPath

Function FFolder(Folder)
  Set Items = ShA.NameSpace(Folder).Items
  For Each TPath In Dic.Keys
    Filt = Dic.Item(TPath)
    Items.Filter 73920, Filt
    For Each F In Items
      F = FSO.GetBaseName(F)
      Set Elems = ShA.NameSpace(Folder).Items
      Elems.Filter 73920, Left(F, 2) &amp; Filt
      Trg = FSO.BuildPath(TPath, UCase(Left(F, 2)))
      If Not FSO.FolderExists(Trg) Then OutDisk.NewFolder(Mid(Trg, 4))
      ShA.NameSpace(Trg).MoveHere Elems, 280
	  Set Items = ShA.NameSpace(Folder).Items
      Items.Filter 73920, Filt
    Next
  Next : Items.Filter 73888, &quot;*&quot;
  For Each F In Items : FFolder F.Path : Next
End Function</code></pre></div></div></div>]]></description>
			<author><![CDATA[null@example.com (Flasher)]]></author>
			<pubDate>Fri, 26 Feb 2016 11:15:16 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=101445#p101445</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: перенос файлов из каталога и его подкаталогов с сортировкой]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=101438#p101438</link>
			<description><![CDATA[<p><strong>Flasher</strong><br />Спасибо</p><p>Если нужно чтобы файлы с разными (заранее известными) расширениями попадали в разные папки так изменить ваш код будет корректно?<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><p>IPath = &quot;T:\FOLDER-1&quot;<br />TPath = &quot;T:\FOLDER-2\FIL&quot;<br />Filt&nbsp; = &quot;*.fil&quot;</p><p>Set FSO&nbsp; &nbsp;= CreateObject(&quot;Scripting.FilesystemObject&quot;)<br />Set Shell = CreateObject(&quot;Shell.Application&quot;)<br />If Not FSO.FolderExists(TPath) Then FSO.CreateFolder TPath<br />FFolder IPath</p><p>Sub FFolder(Folder)<br />	Set Items = Shell.NameSpace(Folder).Items<br />	Items.Filter 73920, Filt<br />	For Each F In Items<br />		Trg = FSO.BuildPath(TPath, UCase(Left(F.Name, 2)))<br />		If Not FSO.FolderExists(Trg) Then FSO.CreateFolder Trg <br />		Shell.NameSpace(Trg).MoveHere F, 280<br />	Next : Items.Filter 73888, &quot;*&quot;<br />	For Each F In Items : FFolder F.Path : Next<br />End Sub</p><p>TPath = &quot;T:\FOLDER-2\TXT&quot;<br />Filt&nbsp; = &quot;*.txt&quot;</p><p>Set FSO&nbsp; &nbsp;= CreateObject(&quot;Scripting.FilesystemObject&quot;)<br />Set Shell = CreateObject(&quot;Shell.Application&quot;)<br />If Not FSO.FolderExists(TPath) Then FSO.CreateFolder TPath<br />FFolder IPath</p><p>Sub FFolder(Folder)<br />	Set Items = Shell.NameSpace(Folder).Items<br />	Items.Filter 73920, Filt<br />	For Each F In Items<br />		Trg = FSO.BuildPath(TPath, UCase(Left(F.Name, 2)))<br />		If Not FSO.FolderExists(Trg) Then FSO.CreateFolder Trg <br />		Shell.NameSpace(Trg).MoveHere F, 280<br />	Next : Items.Filter 73888, &quot;*&quot;<br />	For Each F In Items : FFolder F.Path : Next<br />End Sub</p><p>TPath = &quot;T:\FOLDER-2\LST&quot;<br />Filt&nbsp; = &quot;*.lst&quot;</p><p>Set FSO&nbsp; &nbsp;= CreateObject(&quot;Scripting.FilesystemObject&quot;)<br />Set Shell = CreateObject(&quot;Shell.Application&quot;)<br />If Not FSO.FolderExists(TPath) Then FSO.CreateFolder TPath<br />FFolder IPath</p><p>Sub FFolder(Folder)<br />	Set Items = Shell.NameSpace(Folder).Items<br />	Items.Filter 73920, Filt<br />	For Each F In Items<br />		Trg = FSO.BuildPath(TPath, UCase(Left(F.Name, 2)))<br />		If Not FSO.FolderExists(Trg) Then FSO.CreateFolder Trg <br />		Shell.NameSpace(Trg).MoveHere F, 280<br />	Next : Items.Filter 73888, &quot;*&quot;<br />	For Each F In Items : FFolder F.Path : Next<br />End Sub</p></div></div>]]></description>
			<author><![CDATA[null@example.com (Abashin)]]></author>
			<pubDate>Fri, 26 Feb 2016 09:32:41 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=101438#p101438</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: перенос файлов из каталога и его подкаталогов с сортировкой]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=101437#p101437</link>
			<description><![CDATA[<p><strong>Abashin</strong><br />Добавил указание фильтра в 3 строке.</p>]]></description>
			<author><![CDATA[null@example.com (Flasher)]]></author>
			<pubDate>Fri, 26 Feb 2016 09:15:07 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=101437#p101437</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: перенос файлов из каталога и его подкаталогов с сортировкой]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=101436#p101436</link>
			<description><![CDATA[<p><strong>Flasher</strong>, спасибо - работает!<br />В варианте дла bat-файла я добавлял расширение обрабатываемых файлов из FOLDER-1. Поскольку для файлов с разными расширениями разные папки назначения.<br />А в вашем коде я ничего не понимаю и не знаю куда там можно вставить шаблон, например *.fil</p>]]></description>
			<author><![CDATA[null@example.com (Abashin)]]></author>
			<pubDate>Fri, 26 Feb 2016 08:43:55 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=101436#p101436</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: перенос файлов из каталога и его подкаталогов с сортировкой]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=101432#p101432</link>
			<description><![CDATA[<p><strong>Abashin</strong><br />Пардон, поправил.</p>]]></description>
			<author><![CDATA[null@example.com (Flasher)]]></author>
			<pubDate>Fri, 26 Feb 2016 08:26:16 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=101432#p101432</guid>
		</item>
	</channel>
</rss>
