Skip to content

Instantly share code, notes, and snippets.

@loranallensmith
Created December 16, 2020 15:28
Show Gist options
  • Save loranallensmith/4b7c65c8adbb6c80c47447baf6a232e2 to your computer and use it in GitHub Desktop.
Save loranallensmith/4b7c65c8adbb6c80c47447baf6a232e2 to your computer and use it in GitHub Desktop.
PowerShell Script to Create Numbered Monthly Folders for Organization
# PowerShell Script to Create Numbered Monthly Folders for Storage
# Written by Allen Smith (@loranallensmith)
#
# Takes one parameter -- the start month -- which allows for numbering folders based on fiscal years rather than calendar years.  The default is 1 for January.
Param(
    [int]$startMonth = 1
)
$dateinfo = new-object system.globalization.datetimeformatinfo
$months = $dateinfo.MonthGenitiveNames
for($i=0; $i -lt ($startMonth-1); $i++) {
    $monthValue = $months[0]
    $months = $months[1..11]
    $months = $months + $monthValue
}
for($i=0;$i -lt 12;$i++) {
    $folderName = ($i+1).ToString("00") + "-" + $months[$i]
    md -Name $folderName
#    write-host $folderName
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment