Understood. Sorry I missed that.
Personally I would be a little uncomfortable with this script.
Seems too complex for the task for my taste. I would try to find a more suitable tool for the solution.
In this case I would use JPSoft Take command instead of the built in command processor. The free TCC LE version has the date commands built in along with options for using create instead of modified dates. I am not 100% sure the free version does all you need but I believe it may.
http://jpsoft.com/help/dateranges.htm http://jpsoft.com/help/del.htm?zoom_...delete+by+date
Here is an example line that would delete files and empty subfolders that 10 days or older by create date. It would exclude folder.cfg and include hidden and read only.
del /[dc-10,1/1/80] /[!folder.cfg] /s /x /y i:\*.*
You can do anything in TakeCommand TCC. There is no scripting product better suited for this type of work within windows. Noty even PowerShell has the power of TakeCommand. It allows you to create your own functions, aliases and plugins. Very well supported product as well.
http://jpsoft.com/ If anyone knows of another product with the same power, flexibility, STABILITY and support please let me know.
I recently found this tool that may work for just the deleting aged files but unsure because I have not tested. TCC can be a lot of work initially and unless you require the command processor often it may be overkill.
http://home.mnet-online.de/horst.muc/win/delage.htm
Quite nice really if it suits your need. Deletes by date but no folders unless empty. Perfect for a task I have that must parse through a folder structure with 3 million files and delete those over 95 days. Just unsure I can use it in 64 bit windows. Going to test.
Also if you have access to Experts Exchange there is a very simple vbscript and a Cmd batch file similar to what you wrote but more compact. It may not do what you need precisely though it does have the create date code.
http://www.experts-exchange.com/OS/M..._24129205.html