"Clean up sources before packing them" by SBC Packers
I recently did a walkthrough of the Web Service Software Factory for a group of developers. They are considering its use for their Web Services development. I used the accompanying Hands-On-Lab for the exercise and made some minor modifications to make it "fit" their current environment.
After the walkthrough, I needed to send them a copy of the HOL including the changes I made. That should be easy enough, right? Compress and Send. First, I need to delete all the \bin and \obj directories to keep the compressed file's size to a minimum. Problem is, there are about 10 exercises and each of the solution folder is about 3 levels deep in each exercise folder. I'm lazy so I need to find an easier way. I could have used "Clean Sources" but that would mean running away from a good challenge of doing the same thing using PowerShell [:-)].
Here's my PowerShell script for deleting the \bin and \obj directories under all those solution folders.
The canonical version
get-childitem * -recurse | where-object { $_.PSIsContainer -eq $true } | where-object { $_.Name -eq "bin" -or $_.
Name -eq "obj" } | foreach-object { remove-item -path $_.FullName -recurse -whatif }
This should read like this: "Get everything in this directory and its sub-directories. Select Items which are containers (a.k.a. directories). Select folders whose names are "bin" or "obj". For each folder, delete the folder and all the files/folders that it contains.
The "readable" version (using aliases)
dir * -recurse | where { $_.PSIsContainer -eq $true } | where { $_.Name -eq "bin" -or $_.Name -eq
"obj" } | foreach { remove-item -path $_.FullName -recurse -whatif }
BTW, remove the -whatif in the end if you actually want the command to execute. Keeping the -whatif in allows you to "see" what would happen without actually executing the command.
Groove to Snap's I've got the Power [;-)] Man, I'm really showing my age.