Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete multiple files fast 2

Status
Not open for further replies.

JacobTechy

Programmer
Apr 14, 2005
181
US
I have a folder that has accumulated lots of files (5GB) in the last months. If I try to delete them all at once the OS because very slow and errors out eventually. Is there any way to delete lots of files fast w/o affect system performance.
 
If you delete the folder, it should do it straight away, it will say that the object (The folder) is too big for receycle bin, so will just proceed to clear the FST, where as if you go in the folder, and select all and delete, it really performs a delete on each one.

Hope this Helps.

Neil J Cotton
njc Information Systems
Systems Consultant
 
if you dont want to delete ALL in the folder, create a new folder, move the TBDeleted files (takes no time cause you are just changing the reference on the same driver), and then delete that new folder and its contents.

Hope this Helps.

Neil J Cotton
njc Information Systems
Systems Consultant
 
It would be best if I dont delete the folder. I can try moving the TBDeleted files, but when I open the folder it takes very long for the files to populate in the folder since there is so many.
 
if there is some criteria by which you want to delete them, say folder older than a certain date.

Hope this Helps.

Neil J Cotton
njc Information Systems
Systems Consultant
 
If you want to delete files older than say 30 days for example, you could use something like this

Code:
Dim fso, Folder1, File1, FileCount
Set fso = CreateObject("Scripting.FileSystemObject")
Set Folder = fso.GetFolder("c:\folder")
Set FileCount = Folder.Files
For Each File1 in FileCount
If DateDiff("d", File1.DateLastModified, Now) > 30 Then f1.Delete
Next

put your target folder in the Folder Dec, and the number of days in the datediff comparison, then put that in your windows sceduler to run every night, once a week etc.

Hope this Helps.

Neil J Cotton
njc Information Systems
Systems Consultant
 
so I can type or paste, modify, this code in notepad and then save as a .bat file right? and thats it.
 
no...vbs.
its visual basic script, sorry, I didn't mention that earlier.

Hope this Helps.

Neil J Cotton
njc Information Systems
Systems Consultant
 
You can hold down left shift and then hit delete it will bypass recycle bin and just erase the data.

-DedMeet

"Do What I Say, Not What I Do
 
you can do that too...i forgot about that...the script will automate this task though.

Hope this Helps.

Neil J Cotton
njc Information Systems
Systems Consultant
 
sorry, noticed a small error in my script...the last variable is set to f1, instead of file1

Hope this Helps.

Neil J Cotton
njc Information Systems
Systems Consultant
 
that script came in handy for some of my email folders.

I have deleted the files by first creating a folder and then moving the files and then deleting the create folder.
Worked faster then just deleting all the files within the original folder.

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top