<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Shawson&#039;s Code Blog &#187; Command Line</title>
	<atom:link href="http://www.shawson.co.uk/codeblog/category/command-line/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shawson.co.uk/codeblog</link>
	<description>development notes for my failing memory</description>
	<lastBuildDate>Mon, 26 Jul 2010 19:08:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Command line Batch File to Remove Direcories, using a Wild Card!</title>
		<link>http://www.shawson.co.uk/codeblog/command-line-batch-file-to-remove-direcories-using-a-wild-card/</link>
		<comments>http://www.shawson.co.uk/codeblog/command-line-batch-file-to-remove-direcories-using-a-wild-card/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 14:27:20 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[Batch Scripting]]></category>
		<category><![CDATA[Command Line]]></category>

		<guid isPermaLink="false">http://www.shawson.co.uk/codeblog/?p=393</guid>
		<description><![CDATA[We have a bunch of web services which log details of requests that come in, in folders named using the current date- in the format YYYY-MM-DDD-HH-MM-SS.  I wanted to produce a simple cleanup batch file which we could run every month to bin all logs for transactions which happened 3 months ago- using the [...]


Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/command-line-to-delete-every-file-older-than-30-days/' rel='bookmark' title='Permanent Link: Command line to delete every file older than 30 days'>Command line to delete every file older than 30 days</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/umbraco-installation-folder-permissions-setup/' rel='bookmark' title='Permanent Link: Umbraco Installation &#8211; folder permissions setup'>Umbraco Installation &#8211; folder permissions setup</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>We have a bunch of web services which log details of requests that come in, in folders named using the current date- in the format YYYY-MM-DDD-HH-MM-SS.  I wanted to produce a simple cleanup batch file which we could run every month to bin all logs for transactions which happened 3 months ago- using the dos commands which exist on Windows Server 2003.</p>
<p>The dos &#8220;del&#8221; command allows you to delete using wild cards &#8211; so for example &#8220;dev 2009-07-*&#8221; would erase any files starting with &#8220;2009-07-&#8221;; However this doesn&#8217;t work with folders- so it fell to the rd (remove directory) command- but this doesn&#8217;t support wild cards (I&#8217;m assuming for safety- to stop you permanently erasing 100&#8217;s of folders and their contents accidently- remember there&#8217;s no recycle bin when you delete from the command line!).</p>
<p>To get around this I created a simple Batch file which accepted a wildcard as a parameter, then removes all those folders at the current level (it wont check recursivly).  Just in case this is of use to anyone else, here&#8217;s the code;</p>
<pre>
REM - performs a remove directory, with wildcard matching - example ; rd-wildcard 2007-*
dir %1 /b >loglist.txt
setlocal enabledelayedexpansion
for /f %%a in (./loglist.txt) do (
	rd /s /q %%a
)
del /q loglist.txt
endlocal
</pre>


<p>Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/command-line-to-delete-every-file-older-than-30-days/' rel='bookmark' title='Permanent Link: Command line to delete every file older than 30 days'>Command line to delete every file older than 30 days</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/umbraco-installation-folder-permissions-setup/' rel='bookmark' title='Permanent Link: Umbraco Installation &#8211; folder permissions setup'>Umbraco Installation &#8211; folder permissions setup</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.shawson.co.uk/codeblog/command-line-batch-file-to-remove-direcories-using-a-wild-card/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
