From: Bee on
Dir is dangerous.
Use a different file delete.

Also, may I suggest (settle down now) to use FileSystemObject to both find
and delete files. This has been the best file delete I have seen.
I am currently using a combination of APIs to find, remove attributes and
delete and still run into trouble once in a while deleting a file that will
not delete.

If memory serves using FSO worked; but I have been put off FSO by some
comments in the newsgroup.
But now I am going back since I am doing as you need to do, delete a large
bunch of files since Windows simply cannot do it without getting all wrapped
up in itself.

This happend just today. I had a backup folder with tens of thousands of
files that needed deleting on a 1.5T Drive (lots I wanted to keep, otherwise
I might have formatted the drive).
Windows went stupid while gathering the info to start deleting. what
terrible programming. After ten minutes of gathering i tried to Cancel but
the window went gray. Don't you just hate that? Windows "not responding"
message from MS.
So I killed the stupid window and got my own app going.
I load the top folders names only then recurse down the tree and delete as I
go (also includes a filter for including files, usually set to *).
This is the fastes and gets results immediately, no gathering overhead (of
course no chance to cancel if you change your mind).
Anyway this approach get files deleted very quickly.


"Saga" wrote:

> Hi All,
>
> I have a routine that deletes files that are older than X days. I get the
> file names into an array then I for each filename I determine if it is older
> than X days and if it is I delete it. I use the Dir$() and Kill functions
> for this. It works as expected when there are few files in the folder, but
> takes a loooong time when there are tens of thousand of files.
>
> My peeve is that I need to check the age of the file and delete it only if
> it older than the number of specified days. I searched for different
> routines, but none of them illustrate what I need to do. Does any one have
> any suggestions on an alternative, faster way to do this? Thanks! Saga
>
> PS: I will follow up on Monday.
>
>
> .
>
From: Karl E. Peterson on
Bee wrote:
> This happend just today. I had a backup folder with tens of thousands of
> files that needed deleting on a 1.5T Drive (lots I wanted to keep, otherwise
> I might have formatted the drive).
> Windows went stupid while gathering the info to start deleting. what
> terrible programming. After ten minutes of gathering i tried to Cancel but
> the window went gray. Don't you just hate that? Windows "not responding"
> message from MS.

Jeez, just drop into a CMD window. Windows never has worked well with 1000s of
files in a folder.

> So I killed the stupid window and got my own app going.
> I load the top folders names only then recurse down the tree and delete as I
> go (also includes a filter for including files, usually set to *).
> This is the fastes and gets results immediately, no gathering overhead (of
> course no chance to cancel if you change your mind).
> Anyway this approach get files deleted very quickly.

DEL *.* /S works pretty darn well, too, fwiw. Lots less effort.
--
..NET: It's About Trust!
http://vfred.mvps.org


From: Bee on
Jeez

Part of a app that also wipes files.
I just drag the top folder to it and it deletes or wipes all files with
matching filter.
Less work than a cmd window too and I have control and messages logged that
tell me what the heck is going on unlike Windoze and what is more, it does
not aske me stupid questions like "do you really really really want tooooo."

That is why I code!

DOS - showing your age?
(OK me too but why use DOS when you can code and get all the satisfaction!!!)


"Karl E. Peterson" wrote:

> Bee wrote:
> > This happend just today. I had a backup folder with tens of thousands of
> > files that needed deleting on a 1.5T Drive (lots I wanted to keep, otherwise
> > I might have formatted the drive).
> > Windows went stupid while gathering the info to start deleting. what
> > terrible programming. After ten minutes of gathering i tried to Cancel but
> > the window went gray. Don't you just hate that? Windows "not responding"
> > message from MS.
>
> Jeez, just drop into a CMD window. Windows never has worked well with 1000s of
> files in a folder.
>
> > So I killed the stupid window and got my own app going.
> > I load the top folders names only then recurse down the tree and delete as I
> > go (also includes a filter for including files, usually set to *).
> > This is the fastes and gets results immediately, no gathering overhead (of
> > course no chance to cancel if you change your mind).
> > Anyway this approach get files deleted very quickly.
>
> DEL *.* /S works pretty darn well, too, fwiw. Lots less effort.
> --
> ..NET: It's About Trust!
> http://vfred.mvps.org
>
>
> .
>
From: Karl E. Peterson on
Bee wrote:
> DOS - showing your age?
> (OK me too but why use DOS when you can code and get all the satisfaction!!!)

If you're having fun, by all means, play on.

Sounded to me more like you were whining. <shrug>
--
..NET: It's About Trust!
http://vfred.mvps.org


From: David Kaye on
"Saga" <antiSpam(a)nowhere.com> wrote:

>for this. It works as expected when there are few files in the folder, but
>takes a loooong time when there are tens of thousand of files.

Run the routine hourly? Or maybe every 10 minutes? Or if the software runs
24/7, do it overnight when traffic is slow. Or write a separate application
that just does this housekeeping and thus won't slow down the main program.




--
"You're in probably the wickedest, most corrupt city, most
Godless city in America." -- Fr Mullen, "San Francisco"