Scripting Blog [archived]

Formerly known as the "Hey, Scripting Guy!" blog

Hey, Scripting Guy! How Can I Work with Directories, Files, and Folders by Using Windows PowerShell?

(image) Hey, Scripting Guy! This may not sound too exciting, but I do a lot of work with files and folders. I constantly have to create folders and files, move files, and move folders. This was easy to do by using VBScript, but nevertheless it always required at least six lines of code to do anything. Is it possible to simplify this process ...

Hey, Scripting Guy! How Can I Determine Folder Size?

(image) Hey, Scripting Guy! We are getting ready for a migration, and I am trying to find an easy way to determine the size of the Documents folder. I would like to use Windows PowerShell to do this, but when I use the Get-Item cmdlet to retrieve the properties of a folder, I do not see the size. I really do not want to have to iterate ...

Hey, Scripting Guy! How Can I Delete All the Files in a Folder Except for the Most-Recently Created File?

(image) Hey, Scripting Guy! I have a folder that has about 50 files in it. How can I delete all those files except the one most-recently created?-- GA(image) (image) (image) Hey, GA. You know, today would be a good day to review some of the items that have recently been in the news. (You know that life must be exceedingly dull for the ...

Hey, Scripting Guy! How Can I Monitor a Folder for the Creation of New Subfolders?

(image) Hey, Scripting Guy! How can I monitor a folder for the creation of new subfolders? I know that new files can be detected (via WMI events) but the same syntax doesn't detect new folders.-- WS(image) (image) (image) Hey, WS. Before we get started today can we ask you a quick question: are you reading today’s column? If you aren’t...

Hey, Scripting Guy! How Can I Find Folders Whose Name Fits a Specified Pattern?

(image) Hey, Scripting Guy! I have a bunch of folders that had names like this: BAD_20080411; in other words, the characters BAD_ followed by the date. These folders can be on any drive on my computer. How can I write a script that will locate all these folders for me?-- NS (image) (image) (image) Hey, NS. Did you hear about the construction...