|
Answer» Hello all,
My requirement is to get the date of a specific folder and to delete the same if the folder creation date is more than some 2 weeks.
can any one help me in this.
thanks in advance.Batch code does not do date/time arithmetic very well. I have snippets in my closet going back to 1983, but not one of them does aging in batch code.
How about a nice VBScript solution?
Let us KNOW. spshanth
I wish you luck, but I fear you will get a lot more experience than you want !!!
Created in 2003 I have C:\Windows. This is MUCH MORE than 2 weeks old.
If I applied the RULE of deleting a folder when it was two weeks old, it would save 4.7 GB of disc space, but I would not be able to do much with all that extra space but no operating system.
The date of a folder does NOT indicate its most recent contents; it just possibly corresponds to the most recent file dates at the "root" of this folder, but ignores any more recent dates of folders and subsequent files it may contain.
Whatever the rules (if any) may be, they PROBABLY depend upon whether you are looking at "Created" or "Modified". There are no rules for "ACCESSED". If you use Windows Explorer to look in an obscure region you have not looked at for some time, you may see an ancient "Accessed" date. This is meaningless. If you reboot the computer you will now see it was accessed 5 minutes ago. Accessed does not MEAN the contents were read or written. The "Accessed" date changes if Windows Explorer shows that file exists, but it will NOT change if you use the "DOS" command "DIR".
File dates are interesting, and quite useful, but I would not depend upon them to control what gets deleted.
Regards Alan thanks for the response.
But i have to do this in a DOS batch script only and cannot use VBS here
is there any other way to handle this situation oter than using the date manipualtion logic??
Thnaks.Quote Convert date from MM/DD/YYYY into YYYYMMDD format
Code: [Select]@echo off set dt=mm/dd/yyyy set newdate=%dt:~6,4%%dt:~0,2%%dt:~3,2% echo %newdate%
It becomes problematical when using arithmetic on dates. Everything is fine if both dates are in the same month. The real fun begins when you "borrow" days from the previous month.
I can't sell a VBS script to anyone today. thanks sidewinder...
|