<?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>Amar Kulo &#187; forfiles</title>
	<atom:link href="http://blog.amarkulo.com/tag/forfiles/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.amarkulo.com</link>
	<description>System administration, photography and DIY projects</description>
	<lastBuildDate>Wed, 08 Sep 2010 10:43:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Creating simple cleanup scripts on Windows 2003</title>
		<link>http://blog.amarkulo.com/cleanup-scripts</link>
		<comments>http://blog.amarkulo.com/cleanup-scripts#comments</comments>
		<pubDate>Mon, 10 Nov 2008 14:05:46 +0000</pubDate>
		<dc:creator>Amar Kulo</dc:creator>
				<category><![CDATA[Tips and tricks]]></category>
		<category><![CDATA[2003]]></category>
		<category><![CDATA[bat]]></category>
		<category><![CDATA[batch]]></category>
		<category><![CDATA[clean up]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[forfiles]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://dzo.blogsite.org/?p=175</guid>
		<description><![CDATA[Here is one short tip. If you had problem with old log files that are being held on system after too much time and wanted to delete all of them automatically here is explanation how to do it. open notepad write this line in it Forfiles -p &#8220;c:\temp&#8221; -s -m *.log -d -14 -c &#8220;Cmd [...]]]></description>
			<content:encoded><![CDATA[<p>Here is one short tip. If you had problem with old log files that are being held on system after too much time and wanted to delete all of them automatically here is explanation how to do it.</p>
<ol>
<li>open notepad</li>
<li>write this line in it <strong>Forfiles -p &#8220;c:\temp&#8221; -s -m *.log -d -14 -c &#8220;Cmd /C del @FILE&#8221;</strong></li>
<li>save file and then change it extension from .txt to .bat</li>
</ol>
<p>So here we have batch file created that will do following:</p>
<ul>
<li>find all <strong>.log</strong> files in <strong>c:\temp</strong> path</li>
<li>older than <strong>14 days</strong></li>
<li>and <strong>delete </strong>them</li>
</ul>
<p>Here is small explanation of the command line:</p>
<ul>
<li><strong>-p &#8220;full path&#8221; </strong>is used to specify exact path to the destination dir, it can be c:\ or c:\temp</li>
<li><strong>-s </strong>says to forfiles that it will go recursive into subdirs</li>
<li><strong>-m *.ext </strong>creates filter for files of the <strong>.ext </strong>extension, it can be<strong> *.* </strong>as well</li>
<li><strong>-d 7</strong> says to forfiles to filter files from output above to match current date minus number of days</li>
<li><strong>-c &#8220;command&#8221;</strong> executes command on files that are returned from output of forfiles command</li>
<li><strong>cmd /c command</strong> is saying to <strong>cmd</strong> that is command prompt to execute command and terminate itself</li>
</ul>
<p>Now to test this batch file you can delete or comment out command part so you will get output from forfiles only without deleting of the files. Also you can use move command instead of del to move logfiles to another location.</p>
<p>If everything works like it should open Start-&gt;Control panel-&gt;Scheduled tasks and create new task to executes every day or in any time frame that you want.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.amarkulo.com/cleanup-scripts/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
