<?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=9136&amp;type=atom" />
	<updated>2014-01-13T07:01:14Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=9136</id>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Удаление определенных папок]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=79142#p79142" />
			<content type="html"><![CDATA[<p>На всякий случай ещё два варианта:</p><br /><div class="codebox"><pre><code>@echo off
set Directory_for_Cleanup=D:\TEST
for /f &quot;tokens=*&quot; %%i in (&#039;dir /b /ad &quot;%Directory_for_Cleanup%&quot;&#039;) do (
 for /f %%j in (&#039;^(type &quot;%~f0&quot;^|more +10^&amp;dir /b /a:d &quot;%Directory_for_Cleanup%&quot;^)^|findstr /i /x %%i^|find /c /i /v &quot;&quot;&#039;) do (
  if %%j==1 rd /s /q &quot;%Directory_for_Cleanup%\%%i&quot;
))
echo Cleanup completed.
pause&gt;nul
exit

test5
test6</code></pre></div><br /><div class="codebox"><pre><code>@echo off
set Directory_for_Cleanup=D:\TEST
for /f &quot;tokens=*&quot; %%i in (&#039;dir /a:d /b &quot;%Directory_for_Cleanup%&quot;&#039;) do type &quot;%~f0&quot;|more +7|findstr /i /x &quot;%%i&quot;&gt;nul||rd /s /q &quot;%Directory_for_Cleanup%\%%i&quot;
echo Cleanup completed.
pause&gt;nul
exit

test5
test6</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Yury]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30230</uri>
			</author>
			<updated>2014-01-13T07:01:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=79142#p79142</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Удаление определенных папок]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=79141#p79141" />
			<content type="html"><![CDATA[<p>Yury.</p><p>Большое вам спасибо. все работает как надо.</p>]]></content>
			<author>
				<name><![CDATA[aksenov_ivan]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31560</uri>
			</author>
			<updated>2014-01-13T06:24:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=79141#p79141</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Удаление определенных папок]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=79066#p79066" />
			<content type="html"><![CDATA[<p>Ещё один вариант (&quot;экзотический&quot;):</p><div class="codebox"><pre><code>@set Directory_for_Cleanup=D:\TEST

@echo off
set temp_folder=%temp%\%random%
Robocopy &quot;%Directory_for_Cleanup%&quot; &quot;%temp_folder%&quot; /E /MOVE /XD test5 test6 &gt;nul
rd /s /q &quot;%temp_folder%&quot;
echo Cleanup completed.
pause&gt;nul</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Yury]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30230</uri>
			</author>
			<updated>2014-01-10T18:26:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=79066#p79066</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Удаление определенных папок]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=79065#p79065" />
			<content type="html"><![CDATA[<p>Ниже приведён один из способов (<a href="http://forum.script-coding.com/viewtopic.php?pid=75579#p75579">о его существовании</a> говорил и <strong>Smitis</strong>).</p><div class="codebox"><pre><code>@set Directory_for_Cleanup=D:\TEST
@for /f &quot;usebackq eol=@ tokens=*&quot; %%i in (&quot;%~f0&quot;) do @attrib +h &quot;%Directory_for_Cleanup%\%%i&quot;
@for /d %%i in (&quot;%Directory_for_Cleanup%\*&quot;) do @rd /s /q &quot;%%~i&quot;
@for /f &quot;usebackq eol=@ tokens=*&quot; %%i in (&quot;%~f0&quot;) do @attrib -h &quot;%Directory_for_Cleanup%\%%i&quot;
@echo Cleanup completed.
@pause&gt;nul
@exit

test5
test6</code></pre></div><p>Только будьте крайне осторожны с командой &quot;<strong>rd</strong>&quot;, тестируйте код, заменяя в нём &quot;<strong>rd</strong>&quot; на &quot;<strong>echo</strong>&quot;.</p>]]></content>
			<author>
				<name><![CDATA[Yury]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30230</uri>
			</author>
			<updated>2014-01-10T17:17:21Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=79065#p79065</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Удаление определенных папок]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=79063#p79063" />
			<content type="html"><![CDATA[<p>В чём разница?</p>]]></content>
			<author>
				<name><![CDATA[shiz]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26249</uri>
			</author>
			<updated>2014-01-10T16:50:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=79063#p79063</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Удаление определенных папок]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=79061#p79061" />
			<content type="html"><![CDATA[<p>как игнорировать файлы я тоже понял, а как игнорировать папки???????</p>]]></content>
			<author>
				<name><![CDATA[aksenov_ivan]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31560</uri>
			</author>
			<updated>2014-01-10T15:22:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=79061#p79061</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Удаление определенных папок]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=79060#p79060" />
			<content type="html"><![CDATA[<p><a href="http://forum.script-coding.com/viewtopic.php?id=8461">CMD/BAT: Как игнорировать файлы при удалении?</a></p>]]></content>
			<author>
				<name><![CDATA[shiz]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26249</uri>
			</author>
			<updated>2014-01-10T15:14:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=79060#p79060</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[CMD/BAT: Удаление определенных папок]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=79059#p79059" />
			<content type="html"><![CDATA[<p>Привет форумчане. Задача&nbsp; такова: На диске D есть расшаренная папка TEST, в ней куча подпапок (test1, test2 и т.д), так вот нужно удалить всё из папки TEST, но не удалять некоторые подпапки и их содержимое (например test5 и test6).</p><p>как удалить всё я разобрался, а вот как оставить некоторые подпапки и их содержимое, до меня не доходит.<br />удаляю так:<br /></p><div class="codebox"><pre><code>for %%i in (&quot;D:\TEST&quot;) do (

    pushd %%i &amp;&amp; 2&gt;nul rd /s /q .
    popd
)
</code></pre></div><p>что и куда надо прописать. заранее спасибо</p>]]></content>
			<author>
				<name><![CDATA[aksenov_ivan]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31560</uri>
			</author>
			<updated>2014-01-10T11:30:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=79059#p79059</id>
		</entry>
</feed>
