<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; CMD/BAT: команды dir и sort]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6503&amp;type=atom" />
	<updated>2011-12-05T02:30:29Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=6503</id>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: команды dir и sort]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54261#p54261" />
			<content type="html"><![CDATA[<p>Спасибо!<br />С Уважением Евгений!</p>]]></content>
			<author>
				<name><![CDATA[GrukhvinEV]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27368</uri>
			</author>
			<updated>2011-12-05T02:30:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54261#p54261</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: команды dir и sort]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54204#p54204" />
			<content type="html"><![CDATA[<p>сортировка по расш. (&quot;.&quot; это разделитель в дате)<br />*длинные имена идут лесом<br /></p><div class="codebox"><pre><code>dir /-n |find &quot;.&quot; |sort /+10</code></pre></div><p>по дате – да, будет геморройно</p>]]></content>
			<author>
				<name><![CDATA[!k]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26608</uri>
			</author>
			<updated>2011-12-03T15:57:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54204#p54204</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: команды dir и sort]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54202#p54202" />
			<content type="html"><![CDATA[<p><strong>!k</strong>, это-то понятно. Проблема в том, что надо:</p><p>* отрезать нижние две строки с итогом (верхние режутся обычным skip при разборе);<br />* «разворачивать» дату в формат YYYY.MM.DD для корректной сортировки таким способом, а для выдачи «разворачивать» дату обратно;<br />* для сортировки таким способом по расширению надо выполнять подобные же весьма нетривиальные действия.</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2011-12-03T15:13:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54202#p54202</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: команды dir и sort]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54196#p54196" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Rumata пишет:</cite><blockquote><p>Никак. Сортировка производится для строк сформированного входного потока, где нет полей.</p></blockquote></div><div class="quotebox"><cite>SORT/? пишет:</cite><blockquote><p>/+n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Задает число символов, n, до начала каждого<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; сравнения. /+3 показывает, что каждое<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; сравнение будет начинаться с третьего символа<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; каждой строки. Строки меньше чем n символов<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; собираются перед всеми остальными строками.<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; По умолчанию, сравнение начинается с первого<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; символа каждой строки.</p></blockquote></div>]]></content>
			<author>
				<name><![CDATA[!k]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26608</uri>
			</author>
			<updated>2011-12-03T11:35:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54196#p54196</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: команды dir и sort]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54179#p54179" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>GrukhvinEV пишет:</cite><blockquote><p>как ключами команды sort отсортировать по разным полям, типа по имени, размеру, типу файла, дате.</p></blockquote></div><p>Никак. Сортировка производится для строк сформированного входного потока, где нет полей. </p><p>Замечание:<br />Команда вида<br /></p><div class="codebox"><pre><code>if errorlevel N</code></pre></div><p>работает как <br /></p><div class="codebox"><pre><code>если errorlevel больше либо равно N</code></pre></div><p>Это значит, что Вам следует изменить порядок проверок на обратный, то есть должно быть<br /></p><div class="codebox"><pre><code>IF ERRORLEVEL 4 goto 4
IF ERRORLEVEL 3 goto 3
IF ERRORLEVEL 2 goto 2
IF ERRORLEVEL 1 goto 1</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Rumata]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24846</uri>
			</author>
			<updated>2011-12-03T01:53:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54179#p54179</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: команды dir и sort]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54175#p54175" />
			<content type="html"><![CDATA[<p>Да это понятно, только вот как ключами команды sort отсортировать по разным полям, типа по имени, размеру, типу файла, дате.</p>]]></content>
			<author>
				<name><![CDATA[GrukhvinEV]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27368</uri>
			</author>
			<updated>2011-12-03T01:09:51Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54175#p54175</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: команды dir и sort]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54163#p54163" />
			<content type="html"><![CDATA[<p>dir параметры | sort параметры &gt; файл</p>]]></content>
			<author>
				<name><![CDATA[Smitis]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5649</uri>
			</author>
			<updated>2011-12-02T19:17:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54163#p54163</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[CMD/BAT: команды dir и sort]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54028#p54028" />
			<content type="html"><![CDATA[<p>Условие:&quot;Разработать командный файл, который помещает список файлов текущего каталога в текстовый файл и в зависимости от ключа сортирует по какому-либо полю. Реализовать два варианта: с использованием только команды DIR, с использованием команд DIR и SORT.&quot;<br />С использованием команды dir, я написал, все работает, но вот как отсортировать командой sort не пойму, требуется помощь.<br />Только с командой dir:<br /></p><div class="codebox"><pre><code>@ECHO off
set /p pset=&quot;Enter dir:&quot;
echo Dir: %pset%
echo Sort 1-name 2-size 3- date 4-type
CHOICE /C:1234
IF ERRORLEVEL 1 goto 1
IF ERRORLEVEL 2 goto 2
IF ERRORLEVEL 3 goto 3
IF ERRORLEVEL 4 goto 4
:1
Dir %pset% /a:-d /b /o:n &gt; Sort_files_name.txt
echo Save to Sort_files_name.txt
pause
exit
:2
Dir %pset% /a:-d /b /o:s &gt; Sort_files_size.txt
echo Save to Sort_files_size.txt
pause
exit
:3
Dir %pset% /a:-d /b /o:d &gt; Sort_files_date.txt
echo Save to Sort_files_date.txt
pause
exit
:4
Dir %pset% /a:-d /b /o:e &gt; Sort_files_type.txt
echo Save to Sort_files_type.txt
pause
exit</code></pre></div>]]></content>
			<author>
				<name><![CDATA[GrukhvinEV]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27368</uri>
			</author>
			<updated>2011-11-30T02:35:50Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54028#p54028</id>
		</entry>
</feed>
