DONE: Folder Cleaner -
Welcome Guest.   Make a donation to an author on the site August 30, 2015, 02:54:55 AM  *

Please login or register.
Or did you miss your validation email?

Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.

You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
The N.A.N.Y. Challenge 2013! Download dozens of custom programs!
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: DONE: Folder Cleaner  (Read 5716 times)
Posts: 17

View Profile Give some DonationCredits to this forum member
« on: October 31, 2005, 02:59:02 PM »

Example #1: I have a folder in which is put one copy of every screenshot I take.  I would like to keep them around for a certain time, then delete them. 

Example #2: Or perhaps I just want to have 14 files in there maximum.  And when more than 14 are found, the oldest ones are deleted to keep the count to 15 or less. 

The program I am suggesting would store cleanup settings for each folder the user wants "cleaned" periodically.  It would also perform those cleaning tasks when initiated (like at startup).

Possible Cleaning Methods...
  • Delete files older than a certain number of days (or hours, etc.) old.
  • Delete oldest files when the maximum file count for that folder is reached or exceeded.
  • Delete oldest files when the maximum total file size for that folder is reached or exceeded (i.e. when all files' size adds to more than specified amount, oldest are deleted until max is reached or passed.).
  • Delete files that do not have a certain string in their name.
  • Delete files whose names do not match a certain regular expression.
  • Delete text files that do not have a certain string in their content.
  • Delete text files whose content does not match a certain regular expression.

There are probably more cleaning methods out there, but these might be the most common.  The first three were really the ones that spawned this idea.  The others just came as I was thinking on how to make it better.

And perhaps you could put a certain filter on the first three options.  Like, skip all .html files, but clean all jpg files.

I know windows cleanup is nice, but as far as I can tell, it just deletes them all, rather than keeping the most recent, etc.
Coding Snacks Author
Charter Honorary Member
Posts: 2,769

View Profile Give some DonationCredits to this forum member
« Reply #1 on: November 01, 2005, 11:58:45 AM »

If you'd like to try your own hand at scripting, I have an Autohotkey script (can't swing a dead cat around DonationCoder without hitting one...) that might get you started. It's quite a bare-bones script I use to clean the temp folders here at work that basically sends to the recycle bin all files inside all folders in z:\temp\dir. For walk-in customers we use a directory of temp folders labeled temp1-temp9 in the temp dir and it was such a pain to go in and clean out every one at the end of the day I did this:
[copy or print]
msgbox,52,Clean Folder,Are you sure you want to clean Temp folder?
if msgbox,no

msgbox,0,Clean Folder,Temp Directory clean!
This probably isn't exactly what you need, but take a look at the "File Loop" entry in the AHK help file and there you'll find that you can sequentially select files for action (delete,recycle,rename, whatever) based on their creation or modified date or anything, really. And settings can be stored in a standard .ini file and subsequently read using the IniWrite/Iniread functions or even store values in the Registry with RegWrite/RegRead like the Pros do!  Check it out.

All children left unattended will be given a mocha and a puppy.
First Author
Posts: 34,919

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #2 on: November 01, 2005, 01:10:10 PM »

i love this idea for a reall flexible clearning system -
personally i'd also love to see it so you could right click on a directory and apply the rules,.

and most of all i'd like to get a report in the form of a checklist before it actually does anything, so i could unselect stuff i didn't want deleted.

i've seen some related programs for cleaning temporary program files - if you find a good solution let us know.

definitely sounds like a nice utility for someone looking for something to program, though might be a bit bigger than a coding snack, at least what i'm thinking about.
Posts: 12

View Profile Give some DonationCredits to this forum member
« Reply #3 on: December 28, 2006, 09:43:35 AM »

I was looking for something like this and found this thread.  I'm looking for something I can just set a rule on a folder to delete files older than x days.  Maybe it could run as a scheduled task every night to make the coding easier.
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register | About Us Forum | Powered by SMF
[ Page time: 0.037s | Server load: 0.03 ]

Share on Facebook
submit to reddit