I have spent about a week on this task, and I know I am nowhere near an expert on Powershell, I am running into a wall.
Here is what I want to accomplish - I have a folder with 1000's of files going back three years. I want to write a PS script that will move all the files older than three months into archive folders based on the file creation date. I need two levels, Year and inside the year, month.
Here is what I have so far
$location = "C:\scripts\Test1"
cd $location
dir | ?{$_.psiscontainer -eq $false}| %{$a="$($_.creationtime.year.ToString())";mkdir -ea 0 $a;mv $_ $a}
$locationYear = "C:\Scripts\Test1\$a"
cd $locationYear
dir | ?{$_.psiscontainer -eq $false}| %{$b="$($_.creationtime.month.ToString())";mkdir -ea 0 $b;mv $_ $b}
I know its basic, but it is working so far, except the folder month is in numeral format, 3 not 03. This is a requirement from our development team.
Any help would be appreciated, Thanks!