A project I am working on is going to require me to move folders based on a certain date from one folder to another. The first six characters of the folder name contain the date. What I am going to need to do is specify that any folders with a date less than today move to another location. An example of a folder name is 071311080901_35P1CTN I know in SSIS there is a FOR EACH LOOP container but I don't have any experience with using it. I know there is a file enumerator but there isn't one for folders. Before I spend countless hours or possibly days trying to engineer this process I thought I would seek out advice and guidance from the community on how best to approach this. A bit more about the project and why this is even my responsibility as the DBA has to do with the fact that the movement of the folders has to occur and a data load. The folders can only move once a dataset is built from our outsourced processor. I decided to write a blog about this since I was so excited to finally adopt PowerShell and to write my first script. [Here is the link for "My First PowerShell Script to Move Folders"](
So here is my solution. $yest = (get-date).AddDays(-1).ToString('MMddyy') Move-Item c:\\\Posh\\\Branch\\\$yest* c:\\\Posh\\\Moved I am truly amazed that Posh can handle all of this in two freaking lines of code. I do believe we have a new Posh addict. Aaron Nelson will be proud.