<?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: Delete files older than certain number of days</title>
	<atom:link href="http://www.jjclements.co.uk/2008/07/31/delete-files-older-than-certain-number-of-days/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jjclements.co.uk/2008/07/31/delete-files-older-than-certain-number-of-days/</link>
	<description>Clem&#039;s Technical Blog</description>
	<lastBuildDate>Sat, 04 Feb 2012 11:28:18 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Danny</title>
		<link>http://www.jjclements.co.uk/2008/07/31/delete-files-older-than-certain-number-of-days/#comment-2031</link>
		<dc:creator>Danny</dc:creator>
		<pubDate>Fri, 22 Jul 2011 07:26:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.jjclements.co.uk/?p=66#comment-2031</guid>
		<description>If you want to deleted UNC paths, without mapping your self use this script...

net use k: \\unc\path\here username password
forfiles.exe /p k:\logs /s /m *.* /d -30 /c &quot;cmd /c del /q @path&quot;
net use k: /d

Hope this can help someone... this way you can run the script without mapping a drive everytime.</description>
		<content:encoded><![CDATA[<p>If you want to deleted UNC paths, without mapping your self use this script...</p>
<p>net use k: \\unc\path\here username password<br />
forfiles.exe /p k:\logs /s /m *.* /d -30 /c "cmd /c del /q @path"<br />
net use k: /d</p>
<p>Hope this can help someone... this way you can run the script without mapping a drive everytime.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Radame</title>
		<link>http://www.jjclements.co.uk/2008/07/31/delete-files-older-than-certain-number-of-days/#comment-1951</link>
		<dc:creator>Radame</dc:creator>
		<pubDate>Sun, 26 Dec 2010 06:45:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.jjclements.co.uk/?p=66#comment-1951</guid>
		<description>James:

Are there any way to bypass the confirmation of delete in Windows 7.
I have some security cameras installed and they are recording to a hard drive, so I delete the videos older than a month, but every time I run this command Windows 7 CMD asks me if I want it to delete the files.
I tried running it from a bat file but it does not delete any thing.

Please help me out.</description>
		<content:encoded><![CDATA[<p>James:</p>
<p>Are there any way to bypass the confirmation of delete in Windows 7.<br />
I have some security cameras installed and they are recording to a hard drive, so I delete the videos older than a month, but every time I run this command Windows 7 CMD asks me if I want it to delete the files.<br />
I tried running it from a bat file but it does not delete any thing.</p>
<p>Please help me out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eitan</title>
		<link>http://www.jjclements.co.uk/2008/07/31/delete-files-older-than-certain-number-of-days/#comment-1754</link>
		<dc:creator>Eitan</dc:creator>
		<pubDate>Tue, 30 Nov 2010 09:52:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.jjclements.co.uk/?p=66#comment-1754</guid>
		<description>I run the forfiles command to delete old files, but when there are no old files to delete it returns an error saying: ERROR: No files found with the specified search criteria.
But it&#039;s fine by me and I don&#039;t want this to be returned as an error. Is there a way to suppress this error?</description>
		<content:encoded><![CDATA[<p>I run the forfiles command to delete old files, but when there are no old files to delete it returns an error saying: ERROR: No files found with the specified search criteria.<br />
But it's fine by me and I don't want this to be returned as an error. Is there a way to suppress this error?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pingram</title>
		<link>http://www.jjclements.co.uk/2008/07/31/delete-files-older-than-certain-number-of-days/#comment-1733</link>
		<dc:creator>pingram</dc:creator>
		<pubDate>Fri, 29 Oct 2010 15:49:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.jjclements.co.uk/?p=66#comment-1733</guid>
		<description>If I wanted to exclude these files / directories it is searching in how would i do that?

thanks
phyl</description>
		<content:encoded><![CDATA[<p>If I wanted to exclude these files / directories it is searching in how would i do that?</p>
<p>thanks<br />
phyl</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pingram</title>
		<link>http://www.jjclements.co.uk/2008/07/31/delete-files-older-than-certain-number-of-days/#comment-1732</link>
		<dc:creator>pingram</dc:creator>
		<pubDate>Fri, 29 Oct 2010 15:15:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.jjclements.co.uk/?p=66#comment-1732</guid>
		<description>oh, and by the way on the c:\temp files i tried earlier they were all really old, over a year old, i had not moved or touched them, the only way i got it to finally work there was this way
Forfiles /p C:\Temp /s /m * /D -5 /c &quot;cmd /c del /q @path&quot;
when i had it this way it would not delete them
Forfiles /p C:\Temp /s /m *.*  /D -5 /c &quot;cmd /c del /q @path&quot;</description>
		<content:encoded><![CDATA[<p>oh, and by the way on the c:\temp files i tried earlier they were all really old, over a year old, i had not moved or touched them, the only way i got it to finally work there was this way<br />
Forfiles /p C:\Temp /s /m * /D -5 /c "cmd /c del /q @path"<br />
when i had it this way it would not delete them<br />
Forfiles /p C:\Temp /s /m *.*  /D -5 /c "cmd /c del /q @path"</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pingram</title>
		<link>http://www.jjclements.co.uk/2008/07/31/delete-files-older-than-certain-number-of-days/#comment-1731</link>
		<dc:creator>pingram</dc:creator>
		<pubDate>Fri, 29 Oct 2010 15:06:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.jjclements.co.uk/?p=66#comment-1731</guid>
		<description>thanks for the update, i will try your update, but here is what someone found and told me, i cannot run it as *.* it will not delete files, if I run it as *, it does delete files, however it still returns the deal about it cannot find these other directories that are not listed in the temp files, that confuses me, why is it even looking for them.  But it does clean up the other files so i am happy, have created a bat file to run automatically, I just tried yours and it did run with the *.*, not sure why yours would and mine would not, hmmm, i looked at the help and could not see what the /f and /s were doing?
thanks</description>
		<content:encoded><![CDATA[<p>thanks for the update, i will try your update, but here is what someone found and told me, i cannot run it as *.* it will not delete files, if I run it as *, it does delete files, however it still returns the deal about it cannot find these other directories that are not listed in the temp files, that confuses me, why is it even looking for them.  But it does clean up the other files so i am happy, have created a bat file to run automatically, I just tried yours and it did run with the *.*, not sure why yours would and mine would not, hmmm, i looked at the help and could not see what the /f and /s were doing?<br />
thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Clements</title>
		<link>http://www.jjclements.co.uk/2008/07/31/delete-files-older-than-certain-number-of-days/#comment-1730</link>
		<dc:creator>James Clements</dc:creator>
		<pubDate>Thu, 28 Oct 2010 22:32:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.jjclements.co.uk/?p=66#comment-1730</guid>
		<description>Hi pingram, OK - working backwards, looking at your last comment first, it seems as though the last thing you tried was to create a folder on your C:\ called Temp and try running fofiles.exe on it. This was your command and output (I&#039;ve copied and pasted exactly what you used):

forfiles.exe /p C:\Temp /s /m *.* /d -30 /c &quot;cmd /c del /q @path&quot;
ERROR: No files found with the specified search criteria.

So... as per the error, no files were found in the folder that were over 30 (you used -30) days old. Did you definitely put files in there that were older than 30 days? If you didn&#039;t then the output you received is the correct one  as there would have been nothing for forfiles.exe to delete. I have just copied and pasted your command myself having first created a C:\Temp folder and verified that everything is as it should be. If I place a file (I just grabbed a random one from my hard drive) in C:\Temp that is older than 30 days it does get removed. If there is nothing in C:\Temp older than 30 days then I correctly get &quot;ERROR: No files found with the specified search criteria&quot;. So the program is actually behaving as expected isn&#039;t it?

Moving on, with reference to your first comment - you wish to tidy the C:\WINDOWS\Temp folder. OK, a couple of things here, firstly some running programs/applications use this folder to temporarily store log files. So, if you run forfiles.exe to try and clean C:\WINDOWS\Temp and there is a file that is open by the system or another program/application, then there is no way that it can be deleted, even if it does meet your criteria of being older than 5 days. Perhaps an easier way of describing this for you is: have you ever opened a Word document located your desktop then forgotten you still had the Word application open (maybe you minimised it for example) and then tried to delete the actual Word document? You would not have been able to - as the word process has a lock on the file. Well this is effectively what could be happening with C:\WINDOWS\Temp. As an example I have just checked my computer and I can see files in there that I know would not be able to be deleted by forfiles.exe or any other program unless the application or system process that has the files open is closed first.

The other point I would like to make is that in the C:\WINDOWS\Temp folder you may have some files with special attributes (such as R=read only files) set. It could be worth trying to modify your command to use a few of the other options that &#039;del&#039; offers. To view a list, in a command prompt type del /? to get them with a description of what each of them does. For example, I would next try to test:

forfiles.exe /p c:\WINDOWS\Temp /s /m *.* /d -5 /c &quot;cmd /c del /q /f /s @path&quot;</description>
		<content:encoded><![CDATA[<p>Hi pingram, OK - working backwards, looking at your last comment first, it seems as though the last thing you tried was to create a folder on your C:\ called Temp and try running fofiles.exe on it. This was your command and output (I've copied and pasted exactly what you used):</p>
<p>forfiles.exe /p C:\Temp /s /m *.* /d -30 /c "cmd /c del /q @path"<br />
ERROR: No files found with the specified search criteria.</p>
<p>So... as per the error, no files were found in the folder that were over 30 (you used -30) days old. Did you definitely put files in there that were older than 30 days? If you didn't then the output you received is the correct one  as there would have been nothing for forfiles.exe to delete. I have just copied and pasted your command myself having first created a C:\Temp folder and verified that everything is as it should be. If I place a file (I just grabbed a random one from my hard drive) in C:\Temp that is older than 30 days it does get removed. If there is nothing in C:\Temp older than 30 days then I correctly get "ERROR: No files found with the specified search criteria". So the program is actually behaving as expected isn't it?</p>
<p>Moving on, with reference to your first comment - you wish to tidy the C:\WINDOWS\Temp folder. OK, a couple of things here, firstly some running programs/applications use this folder to temporarily store log files. So, if you run forfiles.exe to try and clean C:\WINDOWS\Temp and there is a file that is open by the system or another program/application, then there is no way that it can be deleted, even if it does meet your criteria of being older than 5 days. Perhaps an easier way of describing this for you is: have you ever opened a Word document located your desktop then forgotten you still had the Word application open (maybe you minimised it for example) and then tried to delete the actual Word document? You would not have been able to - as the word process has a lock on the file. Well this is effectively what could be happening with C:\WINDOWS\Temp. As an example I have just checked my computer and I can see files in there that I know would not be able to be deleted by forfiles.exe or any other program unless the application or system process that has the files open is closed first.</p>
<p>The other point I would like to make is that in the C:\WINDOWS\Temp folder you may have some files with special attributes (such as R=read only files) set. It could be worth trying to modify your command to use a few of the other options that 'del' offers. To view a list, in a command prompt type del /? to get them with a description of what each of them does. For example, I would next try to test:</p>
<p>forfiles.exe /p c:\WINDOWS\Temp /s /m *.* /d -5 /c "cmd /c del /q /f /s @path"</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pingram</title>
		<link>http://www.jjclements.co.uk/2008/07/31/delete-files-older-than-certain-number-of-days/#comment-1729</link>
		<dc:creator>pingram</dc:creator>
		<pubDate>Thu, 28 Oct 2010 17:25:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.jjclements.co.uk/?p=66#comment-1729</guid>
		<description>I tried this command on the plain old c:\Temp folder that has bunches of old files in it
forfiles.exe /p C:\Temp /s /m *.* /d -30 /c &quot;cmd /c del /q @path&quot;
and it returns

C:\&gt;forfiles.exe /p C:\Temp /s /m *.* /d -30 /c &quot;cmd /c del /q @path&quot;
ERROR: No files found with the specified search criteria.

I don&#039;t get it!!

Any help would be greatly appreciated, I can&#039;t seem to find anyone to do this for me and I guess this outside of my expertise.

thanks
pingram</description>
		<content:encoded><![CDATA[<p>I tried this command on the plain old c:\Temp folder that has bunches of old files in it<br />
forfiles.exe /p C:\Temp /s /m *.* /d -30 /c "cmd /c del /q @path"<br />
and it returns</p>
<p>C:\&gt;forfiles.exe /p C:\Temp /s /m *.* /d -30 /c "cmd /c del /q @path"<br />
ERROR: No files found with the specified search criteria.</p>
<p>I don't get it!!</p>
<p>Any help would be greatly appreciated, I can't seem to find anyone to do this for me and I guess this outside of my expertise.</p>
<p>thanks<br />
pingram</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pingram</title>
		<link>http://www.jjclements.co.uk/2008/07/31/delete-files-older-than-certain-number-of-days/#comment-1728</link>
		<dc:creator>pingram</dc:creator>
		<pubDate>Thu, 28 Oct 2010 16:46:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.jjclements.co.uk/?p=66#comment-1728</guid>
		<description>and what is really weird and scary is that there are no such directories in the C\WINDOWS\Temp directory so, where is it looking that it is returning the above information about not being able to find those directories....
Could Not Find c:\WINDOWS\Temp\History\History.IE5\*
Could Not Find c:\WINDOWS\Temp\History\History.IE5\desktop.ini
Could Not Find c:\WINDOWS\Temp\Temporary Internet Files\Content.IE5\*
Could Not Find c:\WINDOWS\Temp\Temporary Internet Files\Content.IE5\desktop.ini</description>
		<content:encoded><![CDATA[<p>and what is really weird and scary is that there are no such directories in the C\WINDOWS\Temp directory so, where is it looking that it is returning the above information about not being able to find those directories....<br />
Could Not Find c:\WINDOWS\Temp\History\History.IE5\*<br />
Could Not Find c:\WINDOWS\Temp\History\History.IE5\desktop.ini<br />
Could Not Find c:\WINDOWS\Temp\Temporary Internet Files\Content.IE5\*<br />
Could Not Find c:\WINDOWS\Temp\Temporary Internet Files\Content.IE5\desktop.ini</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pingram</title>
		<link>http://www.jjclements.co.uk/2008/07/31/delete-files-older-than-certain-number-of-days/#comment-1727</link>
		<dc:creator>pingram</dc:creator>
		<pubDate>Thu, 28 Oct 2010 16:28:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.jjclements.co.uk/?p=66#comment-1727</guid>
		<description>Oh so close, but can&#039;t seem to get it to work exactly, using windows 2003 server, this is my script I am using and the response... I am trying to clean up WINDOWS\Temp folder, it has files back to 10/13, but it returns the response below on some directories in the temp folder but does not delete any of the files??  Can you tell me what I am doing wrong.

C:\Documents and Settings\Administrator&gt;forfiles.exe /p c:\WINDOWS\Temp /s /m *.
* /d -5 /c &quot;cmd /c del /q @path&quot;

Could Not Find c:\WINDOWS\Temp\History\History.IE5\*
Could Not Find c:\WINDOWS\Temp\History\History.IE5\desktop.ini
Could Not Find c:\WINDOWS\Temp\Temporary Internet Files\Content.IE5\*
Could Not Find c:\WINDOWS\Temp\Temporary Internet Files\Content.IE5\desktop.ini</description>
		<content:encoded><![CDATA[<p>Oh so close, but can't seem to get it to work exactly, using windows 2003 server, this is my script I am using and the response... I am trying to clean up WINDOWS\Temp folder, it has files back to 10/13, but it returns the response below on some directories in the temp folder but does not delete any of the files??  Can you tell me what I am doing wrong.</p>
<p>C:\Documents and Settings\Administrator&gt;forfiles.exe /p c:\WINDOWS\Temp /s /m *.<br />
* /d -5 /c "cmd /c del /q @path"</p>
<p>Could Not Find c:\WINDOWS\Temp\History\History.IE5\*<br />
Could Not Find c:\WINDOWS\Temp\History\History.IE5\desktop.ini<br />
Could Not Find c:\WINDOWS\Temp\Temporary Internet Files\Content.IE5\*<br />
Could Not Find c:\WINDOWS\Temp\Temporary Internet Files\Content.IE5\desktop.ini</p>
]]></content:encoded>
	</item>
</channel>
</rss>

