FOREFILES Removing Directory
Hello, Looking for some help working with FOREFILES for windows 2003 server. I am creating backups on a drive and I would like to use forefiles to go into the drive and delete folders older than 3 days. The backups come in daily, All I want to do is have forefiles delete the folders that are older than 3 days old. I dont want it to go into the folders, I just need the entire folder and its contents deleted if the folder was created 3 days or more. Please any help would be appreciated.
July 8th, 2009 11:03am
Hello,chekc out this one and the included examples:http://technet.microsoft.com/en-us/library/cc753551(WS.10).aspxBest regards
Meinolf Weber
Disclaimer: This posting is provided "AS IS" with no warranties, and confers
no rights.
Free Windows Admin Tool Kit Click here and download it now
July 8th, 2009 2:16pm
Thanks for the reply. But in none of the examples do they show how to delete folders. they talk about files but i am totally lost when it comes to directories. I used to use the older version of forefile to accomplish this, but the format in the new one in server 2003 does not recognize it. unless i am doing something wrong. i believe my old format was forefiles -p D:\backup m/ *.* -d -3 -c "cmd -c rmdir @file s/ q/" this used to look in the directory and delete any folder tha was created 3 days or older. with the forefiles in server 2003 this format does not work. if you can tell what i am doing wrong it will be very appreciated. I am lost thanks
July 8th, 2009 3:06pm
Thanks for the reply. But in none of the examples do they show how to delete folders. they talk about files but i am totally lost when it comes to directories. I used to use the older version of forefile to accomplish this, but the format in the new one in server 2003 does not recognize it. unless i am doing something wrong. i believe my old format was forefiles -p D:\backup m/ *.* -d -3 -c "cmd -c rmdir @file s/ q/"this used to look in the directory and delete any folder tha was created 3 days or older. with the forefiles in server 2003 this format does not work. if you can tell what i am doing wrong it will be very appreciated. I am lostthanks
The directory looks likt thisD:\Backup\07082009BackupSo everyday there is a new backup done within D:\BackupI am just trying to get the script to delete any folder inside of "D:\Backup" that is older than 3 days. I am using Windows server 2003, Any help will be appreciated.Thanks
Free Windows Admin Tool Kit Click here and download it now
July 9th, 2009 9:24am
It's pretty late here and I would like to help more (which I will try to in the morning) but have you tried out just using for?for /D %A in ("C:\home\*") do ECHO %A %~tAhttp://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/for.mspxThis walks down the folders from C:\Home and outputs the folder and its date/time modified stamp. I am pretty sure an if statement could be added to do a conditional rd.I imagine we all could whip up some Vbscript pretty easily for this task too. :)
July 9th, 2009 10:04am
Hi,
If you need further assistance, I suggest that you post to the MSDN forum. The support professionals there are better qualified to assist you regarding scripting.
MSDN forum
http://forums.microsoft.com/msdn/default.aspx?siteid=1
Thanks.
Free Windows Admin Tool Kit Click here and download it now
July 10th, 2009 10:16am


