<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; CMD/BAT: Как игнорировать файлы при удалении?]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=8461&amp;type=atom" />
	<updated>2013-12-29T21:24:15Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=8461</id>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Как игнорировать файлы при удалении?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=78653#p78653" />
			<content type="html"><![CDATA[<p><strong>wisgest</strong>, спасиб</p>]]></content>
			<author>
				<name><![CDATA[Hydrogenium]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30160</uri>
			</author>
			<updated>2013-12-29T21:24:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=78653#p78653</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Как игнорировать файлы при удалении?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=78652#p78652" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Ekklesiast пишет:</cite><blockquote><p>Хотелось бы как-то так:</p></blockquote></div><p>Это элементарно:<br /></p><div class="codebox"><pre><code>set FILEMASK=^
.*\a3dapi.dll$ ^
.*\voice_tweak.exe$ ^
.*\Mssv12.asi$ ^
.*\.wad$
</code></pre></div><p>Только что-то меня берёт сомнение, правильно ли в данном случае составлен шаблон для FINDSTR.<br />По-моему, должно быть так (не проверял):<br /></p><div class="codebox"><pre><code>set FILEMASK=^
^^a3dapi\.dll$ ^
^^voice_tweak\.exe$ ^
^^Mssv12\.asi$ ^
.*\.wad$
</code></pre></div><p>~~~~~~~~~~~~~~~~~~~~<br />По поводу последнего примера до правки:<br /></p><div class="quotebox"><cite>Ekklesiast пишет:</cite><blockquote><p>для удобства надо как-то разместить список игнорируемых файлов в столбик, т.к. в строчку оч. неудобно.</p></blockquote></div><div class="codebox"><pre><code>for %%i in (bin\*.cfg) do ^
  if not &quot;%%~ni&quot;==&quot;auto&quot; ^
  if not &quot;%%~ni&quot;==&quot;config&quot; ^
  if not &quot;%%~ni&quot;==&quot;default&quot; ^
  if not &quot;%%~ni&quot;==&quot;lang&quot; ^
  if not &quot;%%~ni&quot;==&quot;listen&quot; ^
  if not &quot;%%~ni&quot;==&quot;server&quot; ^
  if not &quot;%%~ni&quot;==&quot;skill&quot; ^
  if not &quot;%%~ni&quot;==&quot;violence&quot; ^
    del /f /q &quot;%%~i&quot;
</code></pre></div><div class="codebox"><pre><code>setlocal enabledelayedexpansion
set IF=auto\config\default\lang\listen\server\skill\violence
set IF=\%IF:\=&quot; \%&quot;
set IF=!IF:\=if not &quot;%%~ni&quot;==&quot;!
for %%i in (bin\*.cfg) do %IF% del /f /q &quot;%%~i&quot;
</code></pre></div><div class="codebox"><pre><code>setlocal enabledelayedexpansion
set IF=auto^
\config^
\default^
\lang^
\listen^
\server^
\skill^
\violence
set IF=\%IF:\=&quot; \%&quot;
set IF=!IF:\=if not &quot;%%~ni&quot;==&quot;!
for %%i in (bin\*.cfg) do %IF% del /f /q &quot;%%~i&quot;
</code></pre></div><p><em>(В двух последних примерах исправил «*» на «bin\*.cfg».)</em></p>]]></content>
			<author>
				<name><![CDATA[wisgest]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=3850</uri>
			</author>
			<updated>2013-12-29T21:00:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=78652#p78652</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Как игнорировать файлы при удалении?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=78646#p78646" />
			<content type="html"><![CDATA[<p><strong>wisgest</strong>, Спасиб <img src="//forum.script-coding.com/img/smilies/big_smile.png" width="15" height="15" /></p><br /><br /><p><strong>След. задача:</strong></p><div class="codebox"><pre><code>
set &quot;FILEMASK=.*\a3dapi.dll$&quot;
set &quot;FILEMASK=%FILEMASK% .*\voice_tweak.exe$&quot;
set &quot;FILEMASK=%FILEMASK% .*\Mssv12.asi$&quot;
set &quot;FILEMASK=%FILEMASK% .*\.wad$&quot;
set &quot;FILEPATH=1&quot;
pushd &quot;%FILEPATH%&quot;
for /f &quot;delims=&quot; %%i in (&#039;dir /a:-d /b^|findstr /v /i &quot;%FILEMASK%&quot;&#039;) do del /f /q /a &quot;%%i&quot;
popd
</code></pre></div><p>Как-то неудобно сделал список игнорируемых файлов (их будет штук 20)&nbsp; в столбик.</p><p>Хотелось бы как-то так:</p><div class="codebox"><pre><code>
set &quot;FILEMASK=
.*\a3dapi.dll$
.*\voice_tweak.exe$
.*\Mssv12.asi$
.*\.wad$&quot;
</code></pre></div><p>Заранее огромное спасибо.</p>]]></content>
			<author>
				<name><![CDATA[Hydrogenium]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30160</uri>
			</author>
			<updated>2013-12-29T17:26:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=78646#p78646</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Как игнорировать файлы при удалении?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=78644#p78644" />
			<content type="html"><![CDATA[<p>После проверки замени ECHO на DEL:<br /></p><div class="codebox"><pre><code>set &quot;FILEMASK=.*\.cfg$ .*\.txt$&quot;
set &quot;FILEPATH=P:\subdir&quot;

pushd &quot;%FILEPATH%&quot;
for /f &quot;delims=&quot; %%i in (&#039;dir /a:-d /b^|findstr /v /i &quot;%FILEMASK%&quot;&#039;) do echo &quot;%%i&quot;
popd
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[wisgest]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=3850</uri>
			</author>
			<updated>2013-12-29T16:56:56Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=78644#p78644</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Как игнорировать файлы при удалении?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=78639#p78639" />
			<content type="html"><![CDATA[<p><strong>След. задача:</strong></p><p>Есть папка, мне там нужно удалить все файлы кроме файлов с расширением *.cfg и *.txt<br />Также нужна возможность задавать переменный путь и маски (*.cfg и *.txt), типа так:</p><div class="codebox"><pre><code>
set FILEMASK= *.cfg and *.txt
set FILEPATH= 1

for %%i in (&#039;dir /b /s &quot;%FILEPATH%\*.*&quot;&#039;) do if not &quot;%%~ni&quot;==%FILEMASK% del /f /q &quot;%%~i&quot;
</code></pre></div><p>Подскажите как сделать</p>]]></content>
			<author>
				<name><![CDATA[Hydrogenium]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30160</uri>
			</author>
			<updated>2013-12-29T14:37:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=78639#p78639</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Как игнорировать файлы при удалении?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=75579#p75579" />
			<content type="html"><![CDATA[<p>Ещё способ исключить файлы при удалении - поставить исключаемым файлам атрибуты скрытый и/или системный в любой комбинации командой attrib. После команды del снять атрибуты.<br />Можно наоборот - удаляемым файлам поставить нужные атрибуты, а в команде del использовать ключ /a</p>]]></content>
			<author>
				<name><![CDATA[Smitis]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5649</uri>
			</author>
			<updated>2013-09-27T07:23:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=75579#p75579</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Как игнорировать файлы при удалении?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=73735#p73735" />
			<content type="html"><![CDATA[<p>зачет</p>]]></content>
			<author>
				<name><![CDATA[rost]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30414</uri>
			</author>
			<updated>2013-07-13T15:42:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=73735#p73735</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Как игнорировать файлы при удалении?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=73713#p73713" />
			<content type="html"><![CDATA[<p><strong>rost</strong>, попробуйте на свой страх и риск:<br /></p><div class="codebox"><pre><code>for /f &quot;skip=1 delims=&quot; %%i in (&#039;dir /b /o:-d *.cfg&#039;) do del &quot;%%~i&quot;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[shiz]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26249</uri>
			</author>
			<updated>2013-07-13T12:48:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=73713#p73713</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Как игнорировать файлы при удалении?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=73708#p73708" />
			<content type="html"><![CDATA[<p>добрый день!<br />если задание изменим: удалить все файлы *.cfg, кроме самого &quot;старого&quot; *.cfg<br />как теперь будет выглядеть батник?</p>]]></content>
			<author>
				<name><![CDATA[rost]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30414</uri>
			</author>
			<updated>2013-07-13T09:59:55Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=73708#p73708</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Как игнорировать файлы при удалении?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=73609#p73609" />
			<content type="html"><![CDATA[<p>del</p>]]></content>
			<author>
				<name><![CDATA[Hydrogenium]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30160</uri>
			</author>
			<updated>2013-07-10T09:34:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=73609#p73609</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Как игнорировать файлы при удалении?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=73603#p73603" />
			<content type="html"><![CDATA[<p><span style="color: green"><strong>Ekklesiast</strong>, напишите заголовок темы по-русски.</span></p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2013-07-10T08:35:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=73603#p73603</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Как игнорировать файлы при удалении?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=73602#p73602" />
			<content type="html"><![CDATA[<p>спасиб ))</p>]]></content>
			<author>
				<name><![CDATA[Hydrogenium]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30160</uri>
			</author>
			<updated>2013-07-10T08:30:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=73602#p73602</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Как игнорировать файлы при удалении?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=73596#p73596" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Ekklesiast пишет:</cite><blockquote><p>добавил строку в *.bat</p><p>чё-то не фурычит</p></blockquote></div><p>«Подымите мне очи…»:<br /></p><div class="quotebox"><cite>shiz пишет:</cite><blockquote><p>для пакетного файла &quot;%&quot; надо удвоить</p></blockquote></div>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2013-07-10T07:15:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=73596#p73596</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Как игнорировать файлы при удалении?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=73595#p73595" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>shiz пишет:</cite><blockquote><p>(для пакетного файла &quot;%&quot; надо удвоить)</p></blockquote></div>]]></content>
			<author>
				<name><![CDATA[shiz]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26249</uri>
			</author>
			<updated>2013-07-10T07:15:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=73595#p73595</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Как игнорировать файлы при удалении?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=73593#p73593" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>shiz пишет:</cite><blockquote><div class="codebox"><pre><code>for %i in (*.cfg) do if not &quot;%~ni&quot;==&quot;1&quot; if not &quot;%~ni&quot;==&quot;2&quot; if not &quot;%~ni&quot;==&quot;3&quot; del /f /q &quot;%~i&quot;</code></pre></div></blockquote></div><p>добавил строку в *.bat<br />чё-то не фурычит<br />))</p>]]></content>
			<author>
				<name><![CDATA[Hydrogenium]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30160</uri>
			</author>
			<updated>2013-07-10T06:55:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=73593#p73593</id>
		</entry>
</feed>
