3

We have a challenge in deleting circa X million files that meet a certain criteria - specifically must be over 90 days old and exclude certain file formats. To date, we've been using a multi-threaded powershell script which is good but still not as fast as we need as our ingest processes are creating new files at a high rate.

What I can do to accelerate the deletion of so many files?

shodanshok
  • 52,255
K-Lye
  • 41
  • 4

2 Answers2

1

Agent Ransack is really fast, and supports deleting files based on modified date.

Also, obviously, it will run faster if you shut down all the other processes running on the server.

B00TK1D
  • 685
0

Powershell has a reputation of not being very fast; maybe a batch file using Windows build-in forfiles command can do the trick.

To select and delete all files older than 90 days, you can use something similar to:

forfiles -p "C:\your\dir" /S /D -90 /C "cmd /c del @path"

If this remains too slow, you can use forfiles to fist create a list of the to-be-deleted files, and than use a batch remove command over all files in the list (this can significantly decrease the number of del calls/iterations).

For more informations and other more or less creative mode to delete files, you can see here and here

shodanshok
  • 52,255