ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Finished Programs

DONE: Folder Cleaner

(1/1)

hurricanedavid:
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.

Edvard:
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:
--- ---msgbox,52,Clean Folder,Are you sure you want to clean Temp folder?
if msgbox,no
exit
loop,z:\Temp\Dir\*.*,0,1
{
filerecycle,%a_loopfilefullpath%
}

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.

mouser:
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.

go197:
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.

Navigation

[0] Message Index

Go to full version