<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Не срабатывает ErrorLevel в цикле]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=17856&amp;type=atom" />
	<updated>2023-07-07T17:52:21Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=17856</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Не срабатывает ErrorLevel в цикле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=158686#p158686" />
			<content type="html"><![CDATA[<p>Разложит их все по папкам, создаст одну пустую, и закроется. Я ж говорю, корявенько. Но это стократ лучше ручного раскладывания пары тысяч файлов.</p>]]></content>
			<author>
				<name><![CDATA[Qp]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=43240</uri>
			</author>
			<updated>2023-07-07T17:52:21Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=158686#p158686</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Не срабатывает ErrorLevel в цикле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=158682#p158682" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Qp пишет:</cite><blockquote><div class="codebox"><pre><code>if (aindex_2 &lt; 10)
		ExitApp</code></pre></div></blockquote></div><p>А если число файлов в папке будет кратно 10?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2023-07-07T15:04:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=158682#p158682</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Не срабатывает ErrorLevel в цикле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=158681#p158681" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>так как Loop, D:\wallpapers\*.* будет перебирать только существующие файлы, и остановится, когда они кончатся</p></blockquote></div><p>Вот! С пониманием механизма пришло и решение:<br /></p><div class="codebox"><pre><code>1::
counter := 0

Loop
{
	counter++
	FileCreateDir, D:\test\%counter%
	Sleep, 500

	aindex_2 := 0
	Loop, D:\test\*.*
	{
		if (A_Index &lt; 11)
			FileMove, %A_LoopFileLongPath%, D:\test\%counter%
			
		aindex_2 := A_Index
	}
	if (aindex_2 &lt; 10)
		ExitApp
}
2::
return</code></pre></div><p>Корявенькое, но работает.</p>]]></content>
			<author>
				<name><![CDATA[Qp]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=43240</uri>
			</author>
			<updated>2023-07-07T11:07:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=158681#p158681</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Не срабатывает ErrorLevel в цикле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=158680#p158680" />
			<content type="html"><![CDATA[<p>Тут ситуации отсутствия файла даже не возникнет, так как <em>Loop, D:\wallpapers\*.*</em> будет перебирать только существующие файлы, и остановится, когда они кончатся.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2023-07-07T09:59:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=158680#p158680</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Не срабатывает ErrorLevel в цикле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=158679#p158679" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Qp пишет:</cite><blockquote><p>В результате отсутствия файла, я полагал.</p></blockquote></div><p><a href="http://www.script-coding.com/AutoHotkey/FileMove.html">http://www.script-coding.com/AutoHotkey/FileMove.html</a><br /></p><div class="quotebox"><blockquote><p>Однако, если источник - одиночный файл (не шаблон) и если он не существует, ErrorLevel устанавливается в 0. Чтобы отследить такую ситуацию, используйте IfExist или FileExist() для проверки существования файла-источника перед его перемещением.</p></blockquote></div>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2023-07-07T08:44:30Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=158679#p158679</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Не срабатывает ErrorLevel в цикле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=158678#p158678" />
			<content type="html"><![CDATA[<p>В результате отсутствия файла, я полагал.</p>]]></content>
			<author>
				<name><![CDATA[Qp]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=43240</uri>
			</author>
			<updated>2023-07-07T06:20:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=158678#p158678</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Не срабатывает ErrorLevel в цикле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=158677#p158677" />
			<content type="html"><![CDATA[<p>А в результате чего должен ErrorLevel появиться?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2023-07-07T01:15:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=158677#p158677</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Не срабатывает ErrorLevel в цикле]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=158676#p158676" />
			<content type="html"><![CDATA[<p>Здравствуйте!<br />Захотел раскидать файлы по подпапкам. С помощью Гугла и этого форума написал скрипт. Он отработал на отлично, но не остановился, когда должен был. Хотелось бы понять, на будущее.<br /></p><div class="codebox"><pre><code>;раскидывает файлы по подпапкам:
/*
в цикле - Loop
создаёт новую папку - FileCreateDir
задержка, чтобы успевало создавать папку - Sleep
выделяет - Loop http://forum.script-coding.com/viewtopic.php?id=13425
и перемещает 10 файлов с расширением в новую папку - FileMove
A_LoopFileLongPath - путь к файлу, ВКЛЮЧАЯ САМ ФАЙЛ
кончились файлы - ErrorLevel != 0
завершение скрипта - ExitApp */

1::
counter := 0

Loop
{
	counter++
	FileCreateDir, D:\wallpapers\%counter%
	Sleep, 500

	Loop, D:\wallpapers\*.*
		if A_Index &lt; 11
			FileMove, %A_LoopFileLongPath%, D:\wallpapers\%counter%
		if (ErrorLevel != 0)	;НЕ РАБОТАЕТ! Шпарит, создаёт папки, когда файлы уже кончились!
			ExitApp
}

2::
return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Qp]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=43240</uri>
			</author>
			<updated>2023-07-06T23:47:41Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=158676#p158676</id>
		</entry>
</feed>
