<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Howto: automatically remove files older than &#8216;x&#8217; days</title>
	<atom:link href="http://thebackroomtech.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/feed/" rel="self" type="application/rss+xml" />
	<link>http://thebackroomtech.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/</link>
	<description>serving up the info back room techs everywhere find interesting</description>
	<lastBuildDate>Sun, 07 Nov 2010 18:59:34 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Claudia Camargo</title>
		<link>http://thebackroomtech.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-121</link>
		<dc:creator>Claudia Camargo</dc:creator>
		<pubDate>Tue, 19 Oct 2010 14:31:49 +0000</pubDate>
		<guid isPermaLink="false">http://thebackroomtech.wordpress.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-121</guid>
		<description>I really liked this script. Simple, quick and it worked.
Thanks a lot!</description>
		<content:encoded><![CDATA[<p>I really liked this script. Simple, quick and it worked.<br />
Thanks a lot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tom</title>
		<link>http://thebackroomtech.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-120</link>
		<dc:creator>tom</dc:creator>
		<pubDate>Fri, 01 Oct 2010 13:08:04 +0000</pubDate>
		<guid isPermaLink="false">http://thebackroomtech.wordpress.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-120</guid>
		<description>Hello,

i have a weird issue with this script.
it doesn&#039;t delete the files...
i adjusted it a little bit, and when i do a wscript.echo i see it checks all the files, and when i do some other wscript echo&#039;s i also see that the datediff for example gives a value 63 and my number of days is 60, so when i do a 63 &gt; 60... it says it isn&#039;t..
veryy strange.
Does anyone see the problem?

Option Explicit
&#039;On Error Resume next

&#039;Variables
Dim objStartFolder, objParameters, Datafiles, DataFolder
Dim objAPI, fso, modified, verschil
Dim NumberOfDays, oBag
Dim StateDataType, strReturn

&#039;Set objAPI = CreateObject(&quot;MOM.ScriptAPI&quot;)

Set objParameters = WScript.Arguments
objStartFolder = objParameters(0) &#039;The 0 indicates FolderName is the first argument
NumberOfDays = objParameters(1) &#039;The 1 indicates the amount of days

Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)

Set DataFolder = fso.GetFolder(objStartFolder)
Set DataFiles = DataFolder.Files
For Each Modified in DataFiles
verschil = DateDiff(&quot;D&quot;, Modified.DateLastModified, Now)
	If verschil &gt; NumberOfDays Then
		wscript.echo &quot;verwijderd : &quot; &amp; Modified
		&#039;Modified.Delete
	&#039;else
		&#039;wscript.echo verschil &amp; &quot;niet ouder dan 2 maanden : &quot; &amp; Modified
	end if
&#039;wscript.echo verschil &amp; &quot; : &quot; &amp; NumberOfDays

Next</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>i have a weird issue with this script.<br />
it doesn&#8217;t delete the files&#8230;<br />
i adjusted it a little bit, and when i do a wscript.echo i see it checks all the files, and when i do some other wscript echo&#8217;s i also see that the datediff for example gives a value 63 and my number of days is 60, so when i do a 63 &gt; 60&#8230; it says it isn&#8217;t..<br />
veryy strange.<br />
Does anyone see the problem?</p>
<p>Option Explicit<br />
&#8216;On Error Resume next</p>
<p>&#8216;Variables<br />
Dim objStartFolder, objParameters, Datafiles, DataFolder<br />
Dim objAPI, fso, modified, verschil<br />
Dim NumberOfDays, oBag<br />
Dim StateDataType, strReturn</p>
<p>&#8216;Set objAPI = CreateObject(&#8220;MOM.ScriptAPI&#8221;)</p>
<p>Set objParameters = WScript.Arguments<br />
objStartFolder = objParameters(0) &#8216;The 0 indicates FolderName is the first argument<br />
NumberOfDays = objParameters(1) &#8216;The 1 indicates the amount of days</p>
<p>Set fso = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)</p>
<p>Set DataFolder = fso.GetFolder(objStartFolder)<br />
Set DataFiles = DataFolder.Files<br />
For Each Modified in DataFiles<br />
verschil = DateDiff(&#8220;D&#8221;, Modified.DateLastModified, Now)<br />
	If verschil &gt; NumberOfDays Then<br />
		wscript.echo &#8220;verwijderd : &#8221; &amp; Modified<br />
		&#8216;Modified.Delete<br />
	&#8216;else<br />
		&#8216;wscript.echo verschil &amp; &#8220;niet ouder dan 2 maanden : &#8221; &amp; Modified<br />
	end if<br />
&#8216;wscript.echo verschil &amp; &#8221; : &#8221; &amp; NumberOfDays</p>
<p>Next</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://thebackroomtech.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-119</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Fri, 02 Apr 2010 01:09:35 +0000</pubDate>
		<guid isPermaLink="false">http://thebackroomtech.wordpress.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-119</guid>
		<description>Search &quot;RoboBasket&quot; in google you will find a software which can automatically process your files based on user predefined rules.  You can process your files based on name, size, date, mp3 tag, extension and more other attributes. and choose actions from move, copy, rename, delete and more.  You can create rules with just drag&amp;drop, no programming or script skills needed.</description>
		<content:encoded><![CDATA[<p>Search &#8220;RoboBasket&#8221; in google you will find a software which can automatically process your files based on user predefined rules.  You can process your files based on name, size, date, mp3 tag, extension and more other attributes. and choose actions from move, copy, rename, delete and more.  You can create rules with just drag&amp;drop, no programming or script skills needed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bd</title>
		<link>http://thebackroomtech.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-118</link>
		<dc:creator>bd</dc:creator>
		<pubDate>Wed, 03 Mar 2010 22:00:31 +0000</pubDate>
		<guid isPermaLink="false">http://thebackroomtech.wordpress.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-118</guid>
		<description>Thanks for the original Script i am new to scripting, but this is a huge help!</description>
		<content:encoded><![CDATA[<p>Thanks for the original Script i am new to scripting, but this is a huge help!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: amar</title>
		<link>http://thebackroomtech.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-117</link>
		<dc:creator>amar</dc:creator>
		<pubDate>Mon, 01 Feb 2010 13:17:06 +0000</pubDate>
		<guid isPermaLink="false">http://thebackroomtech.wordpress.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-117</guid>
		<description>Hi Friends,

I am using below query to delete files,

Dim Fso

Dim Directory

Dim Modified

Dim Files

Set Fso = CreateObject(“Scripting.FileSystemObject”)

Set Directory = Fso.GetFolder(“D:\”)

Set Files = Directory.Files

For Each Modified in Files

If DateDiff(“D”, Modified.DateLastModified, Now) &gt; 1 Then Modified.Delete

Next

i received below error when i executed above query please can anyone help me.

D:\delold.vbs(9, 24) Microsoft VBScript compilation error: Invalid character</description>
		<content:encoded><![CDATA[<p>Hi Friends,</p>
<p>I am using below query to delete files,</p>
<p>Dim Fso</p>
<p>Dim Directory</p>
<p>Dim Modified</p>
<p>Dim Files</p>
<p>Set Fso = CreateObject(“Scripting.FileSystemObject”)</p>
<p>Set Directory = Fso.GetFolder(“D:\”)</p>
<p>Set Files = Directory.Files</p>
<p>For Each Modified in Files</p>
<p>If DateDiff(“D”, Modified.DateLastModified, Now) &gt; 1 Then Modified.Delete</p>
<p>Next</p>
<p>i received below error when i executed above query please can anyone help me.</p>
<p>D:\delold.vbs(9, 24) Microsoft VBScript compilation error: Invalid character</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RandiR</title>
		<link>http://thebackroomtech.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-116</link>
		<dc:creator>RandiR</dc:creator>
		<pubDate>Tue, 19 Jan 2010 16:31:45 +0000</pubDate>
		<guid isPermaLink="false">http://thebackroomtech.wordpress.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-116</guid>
		<description>Excellent discussion is going on here. Glad to see some healthy discussion on batch files and scripts.</description>
		<content:encoded><![CDATA[<p>Excellent discussion is going on here. Glad to see some healthy discussion on batch files and scripts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RandiR</title>
		<link>http://thebackroomtech.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-115</link>
		<dc:creator>RandiR</dc:creator>
		<pubDate>Tue, 19 Jan 2010 16:29:38 +0000</pubDate>
		<guid isPermaLink="false">http://thebackroomtech.wordpress.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-115</guid>
		<description>Here is an alternate script that may possibly reduce the lines of code, and also, possibly, provide more control.



# Script DeleteOld.txt
var str folder, diff, list, file
lf -r -n &quot;*&quot; $folder (($ftype==&quot;f&quot;) AND ($fmtime  $list
while ($list  &quot;&quot;)
do
    lex &quot;1&quot; $list &gt; $file
    # system del (&quot;\&quot;&quot;+$file+&quot;\&quot;&quot;)
    echo -e &quot;DEBUG: Deleted file &quot; $file
done



Script is in biterscripting ( http://www.biterscripting.com ). Copy and paste the script code into file &quot;C:/Scripts/DeleteOld.txt&quot;. Call it as follows.

script &quot;C:/Scripts/DeleteOld.txt&quot; folder(&quot;C:/Testing&quot;) diff(&quot;30000000&quot;)

The above script call will delete files older (modified earlier) than 30 days, 00 hrs, 00 mins, 00 sec from folder &quot;C:/Testing&quot; and all its subfolders (and sub-sub folders).

script &quot;C:/Scripts/DeleteOld.txt&quot; folder(&quot;C:/Testing&quot;) diff(&quot;240000&quot;)

will delete files older (modified earlier) than 24 hrs.

script &quot;C:/Scripts/DeleteOld.txt&quot; folder(&quot;C:/Testing&quot;) diff(&quot;3000&quot;)

will delete files older (modified earlier) than 30 mins and 00 seconds.

script &quot;C:/Scripts/DeleteOld.txt&quot; folder(&quot;C:/Testing&quot;) diff(&quot;0&quot;)

will delete files older (modified earlier) than 0 seconds - that is it will delete all the files. This is same as not specifying the diff() argument at all.

etc.


Test the script first in a test folder until you understand how it works. I have commented out (#) the system del command that actually deletes the files. Once you understand the script, you can uncomment that command.</description>
		<content:encoded><![CDATA[<p>Here is an alternate script that may possibly reduce the lines of code, and also, possibly, provide more control.</p>
<p># Script DeleteOld.txt<br />
var str folder, diff, list, file<br />
lf -r -n &#8220;*&#8221; $folder (($ftype==&#8221;f&#8221;) AND ($fmtime  $list<br />
while ($list  &#8220;&#8221;)<br />
do<br />
    lex &#8220;1&#8243; $list &gt; $file<br />
    # system del (&#8220;\&#8221;"+$file+&#8221;\&#8221;")<br />
    echo -e &#8220;DEBUG: Deleted file &#8221; $file<br />
done</p>
<p>Script is in biterscripting ( <a href="http://www.biterscripting.com" rel="nofollow">http://www.biterscripting.com</a> ). Copy and paste the script code into file &#8220;C:/Scripts/DeleteOld.txt&#8221;. Call it as follows.</p>
<p>script &#8220;C:/Scripts/DeleteOld.txt&#8221; folder(&#8220;C:/Testing&#8221;) diff(&#8220;30000000&#8243;)</p>
<p>The above script call will delete files older (modified earlier) than 30 days, 00 hrs, 00 mins, 00 sec from folder &#8220;C:/Testing&#8221; and all its subfolders (and sub-sub folders).</p>
<p>script &#8220;C:/Scripts/DeleteOld.txt&#8221; folder(&#8220;C:/Testing&#8221;) diff(&#8220;240000&#8243;)</p>
<p>will delete files older (modified earlier) than 24 hrs.</p>
<p>script &#8220;C:/Scripts/DeleteOld.txt&#8221; folder(&#8220;C:/Testing&#8221;) diff(&#8220;3000&#8243;)</p>
<p>will delete files older (modified earlier) than 30 mins and 00 seconds.</p>
<p>script &#8220;C:/Scripts/DeleteOld.txt&#8221; folder(&#8220;C:/Testing&#8221;) diff(&#8220;0&#8243;)</p>
<p>will delete files older (modified earlier) than 0 seconds &#8211; that is it will delete all the files. This is same as not specifying the diff() argument at all.</p>
<p>etc.</p>
<p>Test the script first in a test folder until you understand how it works. I have commented out (#) the system del command that actually deletes the files. Once you understand the script, you can uncomment that command.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Priyesh Gaikwad</title>
		<link>http://thebackroomtech.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-114</link>
		<dc:creator>Priyesh Gaikwad</dc:creator>
		<pubDate>Wed, 18 Nov 2009 07:45:55 +0000</pubDate>
		<guid isPermaLink="false">http://thebackroomtech.wordpress.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-114</guid>
		<description>Hi friends,
In reply to very first script. there is
its just to replace &quot; everywhere.  After u copy this text. u can just manually replace &quot; in notepad. bec its just ascii characters gets changed. It will work

Dim Fso

Dim Directory

Dim Modified

Dim Files

Set Fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)

Set Directory = Fso.GetFolder(&quot;I:\Backup Files&quot;)

Set Files = Directory.Files

For Each Modified in Files

If DateDiff(&quot;D&quot;, Modified.DateLastModified, Now) &gt; 3 Then Modified.Delete

Next

Thanx
Priyesh</description>
		<content:encoded><![CDATA[<p>Hi friends,<br />
In reply to very first script. there is<br />
its just to replace &#8221; everywhere.  After u copy this text. u can just manually replace &#8221; in notepad. bec its just ascii characters gets changed. It will work</p>
<p>Dim Fso</p>
<p>Dim Directory</p>
<p>Dim Modified</p>
<p>Dim Files</p>
<p>Set Fso = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)</p>
<p>Set Directory = Fso.GetFolder(&#8220;I:\Backup Files&#8221;)</p>
<p>Set Files = Directory.Files</p>
<p>For Each Modified in Files</p>
<p>If DateDiff(&#8220;D&#8221;, Modified.DateLastModified, Now) &gt; 3 Then Modified.Delete</p>
<p>Next</p>
<p>Thanx<br />
Priyesh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pjdiller</title>
		<link>http://thebackroomtech.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-113</link>
		<dc:creator>pjdiller</dc:creator>
		<pubDate>Tue, 20 Oct 2009 19:21:21 +0000</pubDate>
		<guid isPermaLink="false">http://thebackroomtech.wordpress.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-113</guid>
		<description>A revised version of the recursive script.

option explicit

Dim strStartFolder
Dim iExpiredAge
dim objFSO, objStartFolder


strStartFolder=&quot;c:\testdelete\&quot;
iExpiredAge=90

Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set objStartFolder = objFSO.GetFolder(strStartFolder)

call DeleteFromFolder(objStartFolder,iExpiredAge)




Sub DeleteFromFolder(objFolder,iAge)

dim colFolders, colFiles
dim objSubFolder, objFile

	Set colFolders = objFolder.SubFolders
	For Each objSubFolder In colFolders
		Call DeleteFromFolder(objSubFolder,iAge)
	Next


	Set colFiles = objFolder.Files
	For Each objFile In colFiles
		If DateDiff(&quot;D&quot;, objFile.DateLastModified, Now) &gt; iAge Then objFile.Delete
	Next

End Sub</description>
		<content:encoded><![CDATA[<p>A revised version of the recursive script.</p>
<p>option explicit</p>
<p>Dim strStartFolder<br />
Dim iExpiredAge<br />
dim objFSO, objStartFolder</p>
<p>strStartFolder=&#8221;c:\testdelete\&#8221;<br />
iExpiredAge=90</p>
<p>Set objFSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<br />
Set objStartFolder = objFSO.GetFolder(strStartFolder)</p>
<p>call DeleteFromFolder(objStartFolder,iExpiredAge)</p>
<p>Sub DeleteFromFolder(objFolder,iAge)</p>
<p>dim colFolders, colFiles<br />
dim objSubFolder, objFile</p>
<p>	Set colFolders = objFolder.SubFolders<br />
	For Each objSubFolder In colFolders<br />
		Call DeleteFromFolder(objSubFolder,iAge)<br />
	Next</p>
<p>	Set colFiles = objFolder.Files<br />
	For Each objFile In colFiles<br />
		If DateDiff(&#8220;D&#8221;, objFile.DateLastModified, Now) &gt; iAge Then objFile.Delete<br />
	Next</p>
<p>End Sub</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tej</title>
		<link>http://thebackroomtech.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-112</link>
		<dc:creator>tej</dc:creator>
		<pubDate>Thu, 27 Aug 2009 18:46:34 +0000</pubDate>
		<guid isPermaLink="false">http://thebackroomtech.wordpress.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/#comment-112</guid>
		<description>How do we delete files in subdirectory ?</description>
		<content:encoded><![CDATA[<p>How do we delete files in subdirectory ?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 2/4 queries in 0.001 seconds using disk: basic
Object Caching 291/291 objects using disk: basic

Served from: thebackroomtech.com @ 2012-05-18 00:27:38 -->
