File Deletion

Started by JTaylor, January 17, 2018, 09:21:26 AM

Previous topic - Next topic

JTaylor

Any suggestions for deleting a LOT of files from a directory in a reasonable amount of time?   I have been processing some files using a COM interface of an application and recently discovered that it doesn't clean up after itself and, as a result, ended up with probably 20-30 million files in my Temp directory.  Can't really tell since getting count would take too long.   Upside is it explains why my computer has been acting so weird.  Downside is I have been deleting files non-stop for over a week and probably still have at least 10-12 million to do.   I have been using a command prompt as well as FileDelete() but would love to be able to get back to my project before another week or two so thought I would ask in case I had missed some option.

Thanks.

Jim

td

Assuming you don't have anything you want to keep in your temp directory, have you tried "rmdir /s /q yourtempdirnamehere" from a command prompt?
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

Had considered that but from my reading it made me think it simply went through and deleted files just like "DEL" would and then remove the directory.   Which would mean it would not save any time.   Am I wrong in my understanding?

I am guessing I am grasping at straws and will simply have to wait but hoping there is something I am missing which will speed up the process.

Jim

td

Theoretically, rmdir could possibly be faster than del because on an NTFS system the directory's files can be removed from the MFT by index without having to check the files' names.  But it would all depend on how MSFT implemented rmdir and del.   I have never tested this so I am just speculating and don't know how much if any time is gained by using rmdir instead of del.   
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor


JTaylor

Things I have discovered...or at least have come to believe (open to being wrong)...and maybe this will help someone.

1.  There is no fast way to delete files.   Have been at it over a month and still several million to go.   Thinking I should have just done a backup, excluding my Temp directory, and then a restore.
2.  You cannot do something like FileDelete("a*") and it do anything.  Same thing from the command prompt.  It makes you think you are doing something but it is not.  Wasted a bunch of time discovering that little bit of knowledge.  This might be a good thing to include in the WinBatch documentation where you speak of using wildcards.

Jim

td

Actually FileDelete("a*") does do something.  It deletes any file beginning with the letter 'a' that does not have an extension.    Whereas,   FileDelete("a*.*") deletes any file beginning with the letter 'a' irrespective of the extension.   This behavior has been around in Microsoft's OS since before the days of Windows.  Although I don't believe the cmd del command works that way anymore. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

Probably just forgot that as with many things  :)    Still might be good to note.   

Jim