Solved

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

Posted on 2006-10-19
3
11,406 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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

No single Antivirus application (despite claims by manufacturers) will catch or protect you from all Virus / Malware or Spyware threats. That doesn't stop you from further protecting yourself however - and this article is to show you how.
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
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…

635 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