<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Копирование последней созданной директории]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6501&amp;type=atom" />
	<updated>2011-11-30T15:27:04Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=6501</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Копирование последней созданной директории]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54066#p54066" />
			<content type="html"><![CDATA[<p>А всё понял.<br />Это всё из-за неправильного понимания мною функции FileCopyDir<br />Теперь понял.<br /></p><div class="codebox"><pre><code>FileCopyDir, C:\ZooSala\%File%, E:\Archive</code></pre></div><p>Мы дублируем и меняем это C:\ZooSala\%File% на это&nbsp; E:\Archive.<br />А я ошибочно думал, что мы копируем это C:\ZooSala\%File% вот в это&nbsp; E:\Archive<br />Всё очень тут запутанно.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2011-11-30T15:27:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54066#p54066</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Копирование последней созданной директории]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54064#p54064" />
			<content type="html"><![CDATA[<p>Наверно потому что папка Archive уже существует. Опять же читайте документацию полностью и внимательно.</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2011-11-30T15:07:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54064#p54064</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Копирование последней созданной директории]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54063#p54063" />
			<content type="html"><![CDATA[<p>Действительно, работает.<br />А меня переглючило, что копируется, но без вложенных папок.<br />Объясните, пожалуйста, почему не работало так?<br /></p><div class="codebox"><pre><code>FileCopyDir, C:\ZooSala\%File%, E:\Archive</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2011-11-30T14:42:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54063#p54063</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Копирование последней созданной директории]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54053#p54053" />
			<content type="html"><![CDATA[<p>В сообщении #7 я привёл рабочий пример, где последняя (по времени) папка копируется вместе со всеми вложенными файлами и папками. Вы ответили, что работает. Зачем разрабатывать ещё один алгоритм? Если просто хочется понять пример из справки, то нужно с ней и разбираться.</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2011-11-30T13:23:21Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54053#p54053</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Копирование последней созданной директории]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54050#p54050" />
			<content type="html"><![CDATA[<p>Да, изначально я считал, что это само собой подразумевается.<br />Проще говоря, мне требуется скопировать все файлы, подпапки и все файлы в подпапках в последней созданной директории.<br />Но в принципе, если алгоритм тот же - почему же не копируется?</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2011-11-30T12:06:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54050#p54050</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Копирование последней созданной директории]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54049#p54049" />
			<content type="html"><![CDATA[<p>Вам требуется копировать все файлы, потом все папки? Это не соответствует названию темы и первому сообщению.</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2011-11-30T12:04:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54049#p54049</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Копирование последней созданной директории]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54045#p54045" />
			<content type="html"><![CDATA[<p>Ну да, вначале копируются все файлы, потом все папки.<br />Этот скрипт - пример с помощи.<br />Я его криво опубликовал, поэтому изменил там всё, после вашего ответа</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2011-11-30T09:32:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54045#p54045</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Копирование последней созданной директории]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54044#p54044" />
			<content type="html"><![CDATA[<p>А Вы знаете, зачем он нужен и как работает?</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2011-11-30T09:28:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54044#p54044</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Копирование последней созданной директории]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54043#p54043" />
			<content type="html"><![CDATA[<p>Да, так работает.<br />Спасибо.<br />Но мне необходимо копировать все файлы и подпапки.<br />Поэтому я стал использовать другой код, а в нём опять не работает<br /></p><div class="codebox"><pre><code>Folder1 = C:\ZooSala
Folder2 = С:\Archive
Time_Orig = 0
F10::
Loop, %Folder1%\* ,2
{
FileGetTime, Time, %A_LoopFileFullPath%, C
If (Time &gt; Time_Orig)
    {
    Time_Orig := Time
    File := A_LoopFileName
    }
}
; The following example copies all files and folders inside a folder to a different folder:
ErrorCount := CopyFilesAndFolders(&quot;%Folder1%\%File%\*.*&quot;, &quot;%Folder2%\%File%\&quot;)
if ErrorCount &lt;&gt; 0
    MsgBox %ErrorCount% files/folders could not be copied.

CopyFilesAndFolders(SourcePattern, DestinationFolder, DoOverwrite = false)
; Copies all files and folders matching SourcePattern into the folder named DestinationFolder and
; returns the number of files/folders that could not be copied.
{
    ; First copy all the files (but not the folders):
    FileCopy, %SourcePattern%, %DestinationFolder%, %DoOverwrite%
    ErrorCount := ErrorLevel
    ; Now copy all the folders:
    Loop, %SourcePattern%, 2  ; 2 means &quot;retrieve folders only&quot;.
    {
        FileCopyDir, %A_LoopFileFullPath%, %DestinationFolder%\%A_LoopFileName%, %DoOverwrite%
        ErrorCount += ErrorLevel
        if ErrorLevel  ; Report each problem folder by name.
            MsgBox Could not copy %A_LoopFileFullPath% into %DestinationFolder%.
    }
    return ErrorCount
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2011-11-30T09:27:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54043#p54043</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Копирование последней созданной директории]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54040#p54040" />
			<content type="html"><![CDATA[<p>У меня вот так работает.<br />Хотя без третьей строчки тоже работает, но для порядка лучше оставить.<br /></p><div class="codebox"><pre><code>Folder1 = C:\ZooSala
Folder2 = C:\Archive
Time_Orig = 0
F10::
Loop, %Folder1%\* ,2
{
FileGetTime, Time, %A_LoopFileFullPath%, C
If (Time &gt; Time_Orig)
	{
	Time_Orig := Time
	File := A_LoopFileName
	}
}
FileCopyDir, %Folder1%\%File%, %Folder2%\%File%</code></pre></div>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2011-11-30T09:06:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54040#p54040</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Копирование последней созданной директории]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54037#p54037" />
			<content type="html"><![CDATA[<p>Можно прописать так<br />Time_Orig = 0<br />Но как я понимаю, это не обязательно, так как и без этой строчки в сообщении он показывает название последней созданной директории, но почему-то, змей, не копирует её <img src="//forum.script-coding.com/img/smilies/sad.png" width="15" height="15" /><br /></p><div class="codebox"><pre><code>F10::
Folder = C:\ZooSala
Time_Orig = 0
Loop, %Folder%\* ,2
{
     FileGetTime, Time, %A_LoopFileFullPath%, C
     If (Time &gt; Time_Orig)
     {
          Time_Orig := Time
          File := A_LoopFileName
     }
}
MsgBox, %File%


; The following example copies all files and folders inside a folder to a different folder:
ErrorCount := CopyFilesAndFolders(&quot;C:\Zoosala\%File%\*.*&quot;, &quot;E:\archive&quot;)
if ErrorCount &lt;&gt; 0
    MsgBox %ErrorCount% files/folders could not be copied.

CopyFilesAndFolders(SourcePattern, DestinationFolder, DoOverwrite = false)
; Copies all files and folders matching SourcePattern into the folder named DestinationFolder and
; returns the number of files/folders that could not be copied.
{
    ; First copy all the files (but not the folders):
    FileCopy, %SourcePattern%, %DestinationFolder%, %DoOverwrite%
    ErrorCount := ErrorLevel
    ; Now copy all the folders:
    Loop, %SourcePattern%, 2  ; 2 means &quot;retrieve folders only&quot;.
    {
        FileCopyDir, %A_LoopFileFullPath%, %DestinationFolder%\%A_LoopFileName%, %DoOverwrite%
        ErrorCount += ErrorLevel
        if ErrorLevel  ; Report each problem folder by name.
            MsgBox Could not copy %A_LoopFileFullPath% into %DestinationFolder%.
    }
    return ErrorCount
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2011-11-30T08:27:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54037#p54037</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Копирование последней созданной директории]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54036#p54036" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>If (Time &gt; Time_Orig)</code></pre></div><p>Как проверить это условие? Откуда берётся содержимое переменной Time_Orig?</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2011-11-30T08:11:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54036#p54036</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Копирование последней созданной директории]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54035#p54035" />
			<content type="html"><![CDATA[<p>Переделал скрипт вот в такой.<br />И всё-равно ничего не копируется.<br />В чём ошибка?<br /></p><div class="codebox"><pre><code>F10::
Folder = C:\ZooSala

Loop, %Folder%\* ,2
{
     FileGetTime, Time, %A_LoopFileFullPath%, C
     If (Time &gt; Time_Orig)
     {
          Time_Orig := Time
          File := A_LoopFileName
     }
}
MsgBox, %File%


; The following example copies all files and folders inside a folder to a different folder:
ErrorCount := CopyFilesAndFolders(&quot;C:\Zoosala\%File%\*.*&quot;, &quot;E:\archive&quot;)
if ErrorCount &lt;&gt; 0
    MsgBox %ErrorCount% files/folders could not be copied.

CopyFilesAndFolders(SourcePattern, DestinationFolder, DoOverwrite = false)
; Copies all files and folders matching SourcePattern into the folder named DestinationFolder and
; returns the number of files/folders that could not be copied.
{
    ; First copy all the files (but not the folders):
    FileCopy, %SourcePattern%, %DestinationFolder%, %DoOverwrite%
    ErrorCount := ErrorLevel
    ; Now copy all the folders:
    Loop, %SourcePattern%, 2  ; 2 means &quot;retrieve folders only&quot;.
    {
        FileCopyDir, %A_LoopFileFullPath%, %DestinationFolder%\%A_LoopFileName%, %DoOverwrite%
        ErrorCount += ErrorLevel
        if ErrorLevel  ; Report each problem folder by name.
            MsgBox Could not copy %A_LoopFileFullPath% into %DestinationFolder%.
    }
    return ErrorCount
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2011-11-30T08:04:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54035#p54035</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Копирование последней созданной директории]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54016#p54016" />
			<content type="html"><![CDATA[<p>Точно, нужно было двоечку поставить <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p><div class="codebox"><pre><code>F10::
Folder = C:\ZooSala

Loop, %Folder%\* ,2
{
     FileGetTime, Time, %A_LoopFileFullPath%, C
     If (Time &gt; Time_Orig)
     {
          Time_Orig := Time
          File := A_LoopFileName
     }
}
MsgBox, %File%
FileCopyDir, C:\ZooSala\%File%, E:\Archive</code></pre></div><p>Но почему-то в папку Archive не копирует.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2011-11-29T13:31:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54016#p54016</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Копирование последней созданной директории]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54014#p54014" />
			<content type="html"><![CDATA[<p>Проверьте это:<br /></p><div class="quotebox"><blockquote><p><span class="bbu">Loop (файлы и папки)</span><br />Возвращает указанные файлы или папки по одному/одной. </p><p>Loop, FilePattern [, <strong>IncludeFolders?</strong>, Recurse?]</p></blockquote></div>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2011-11-29T12:59:56Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54014#p54014</id>
		</entry>
</feed>
