Getting Directory Information Fast
By now, you may have noticed I’m always on the lookout for better performing code. This has turned out to be a good habit now that I’m working at athena health, as the pure scale of things is so much larger than places I’ve been at in the past. One piece I’ve never been able to speed up, though, is iterating through folders and files. Nicolas1847, a PowerShell scripter on Spiceworks, has come up with an ingenious method to get simple directory information using Robocopy (of all things), and a colleague at athena health likes to shell out to CMD.exe and use the old DIR command. But are they faster? And if so, which one?
Get File Counts and Size for All Extensions
Inspired from this script, I decided to expand on it and have Powershell get all of the extensions and report on everything. I also decided to pretty up the report using some HTML. Read on for this quick hit!
Get File Sizes by Extension
As I’ve mentioned before, I enjoy trolling the scripts at Spiceworks and converting the vbScripts that are interesting over to Powershell in an attempt to see if I can not only shorten them, but improve them. One interesting example came by last week, the Get File Size for a Specific Extension script. Here’s what I did with it.