Solved

Delete files older then "X" days old through a command line

Posted on 2006-10-19
3
11,397 Views
Last Modified: 2013-12-28
I'm looking for a program that will delete files in a specified folder older then, say a week old.  I need the program to be launched from a command prompt, and the output must be through the command prompt.  Reason being is i'm logging the deletion, and monitoring how much is building up.  I've found a program that works, but the output is not in the command window so i can't capture it into a text file.

Here's the software that works:
DELOLD - http://www.michna.com/software.htm

I'd prefer a free tool, or at least one with a free trial.

Thanks
0
Comment
Question by:cyrusuncc
3 Comments
 
LVL 83

Accepted Solution

by:
oBdA earned 500 total points
ID: 17768462
A rather uncommon, but easy to realize possibility which would remove old files as well as giving you a detailed log how many files and which file size had been deleted would be through robocopy.
Use robocopy to move the files to a folder "Garbage" or whatever, then simply delete the "Garbage" folder. robocopy has extensive log functions, can append to or recreate the log file, can check for a minimum file age.

Windows Server 2003 Resource Kit Tools
http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en

So all you'd need is a little script, for example like this:

@echo off
robocopy "C:\Old Files\" "C:\Garbage\" *.* /s /mov /create /minage:7 /log:"C:\Log Files\DelOld.log"
rd C:\Garbage /s /q

"/s" processes subdirectories (if necessary), "/mov" will move the files after the copy, and to speed things up as well as save space, you can use the "/create" switch; this will not copy the file's content, but just create the folders and files with a size of zero bytes. /minage:7 will only copy files that are at least 7 days old. "/log" will log what happened (/log+... would append to an existing log file).
Other switches (how much to log, for example) are described by robocopy /? and in robocopy.doc in the installation folder.
0
 
LVL 2

Author Comment

by:cyrusuncc
ID: 17769566
Thanks, i'm going to take a look at this.  I think it will work for my purposes!
0
 

Expert Comment

by:swintec
ID: 22304323
great share! I was looking for such a tool!

thx
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now