# encoding: ascii
# api: powershell
# title: Dir for days
# description: Correction of : Creates directories for every day within a given time period.
# version: 0.1
# type: function
# author: dirdays
# license: CC0
# function: Create-DatePaths
# x-poshcode-id: 3856
# x-archived: 2013-01-09T07:24:50
# x-published: 2013-01-02T02:00:00
#
# The previous script failed on my system because it has a different locale. For example: ‘Oct’ would be ‘Okt’. This function eliminates that problem.
# typo fix: line 12 $Destination should be $DestinationPath
#
Function Create-DatePaths {
Param (
[Parameter(Position=0,Mandatory=$True)]
[DateTime] $Start,
[Parameter(Position=1,Mandatory=$True)]
[ValidateScript({$_ -gt $Start})]
[DateTime] $End,
$DestinationPath=(Join-Path $env:UserProfile "Test")
)
0..(New-TimeSpan $Start $End).Days | % {
$TargetPath = Join-Path $DestinationPath $(Get-Date $Start -Format "yyyy\\MM-MMMM\\yyyy-MM-dd")
If (!(Test-Path $TargetPath)) { New-Item $TargetPath -ItemType Directory }
$Start = $Start.AddDays(1)
}
}