In particular this share while only ~100GB has > 3M files on it! Any basic operations like checking folder sizes, applying ACLs, etc are very slow on xM files. Looking at the share with WinDirStat I found that there's a large number of folders each with 20-50K files in each. Furthermore the majority of these files were old (years) and not actively used so we decided to Archive (e.g. Delete) the contents of these folders.
I started by using 7-Zip and there's an option on the Add to Archive screen to "Delete files after compression":
And that's pretty good! ... But not if you've got hundreds of folders to process.
Instead, with a bit of PowerShell, we invoke 7-Zip from a script and use the -sdel switch to remove files after they've been archived. This PS we used to simply to stuff each sub-folder into an archive.
Get-ChildItem . -Directory | ForEach-Object {
$Archive = $_.Name + ".zip"
$Folder = $_.Name + "\"
&"C:\Program Files\7-Zip\7z.exe" a $Archive $Folder -sdel
}Pow!
No comments:
Post a Comment