Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-10-19
3
Medium Priority
?
11,408 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 2000 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

Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When asking a question in a forum or creating documentation, screenshots are vital tools that can convey a lot more information and save you and your reader a lot of time
Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
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…

718 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