Created
December 16, 2020 15:28
-
-
Save loranallensmith/4b7c65c8adbb6c80c47447baf6a232e2 to your computer and use it in GitHub Desktop.
PowerShell Script to Create Numbered Monthly Folders for Organization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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