8.20.2023

PowerShell Script which creates Folders for every month in the specified years in the format yyyyMM

 PowerShell Script which creates Folders for every month in the specified years



       

            
#Creates directories from a specified start year to an end year and 12 months in each year for each month

# Specify where the folders are to be located
Set-Location 'C:\Temp\'

$RootLocation = $PWD


$StartYear = 2023
$EndYear = 2024 
             

foreach($Year in $StartYear..$EndYear)
{
md $Year

    for ($i=01; $i -le 12; $i++)
    {
        if ($i -le 9)
            {
                $foldername = (-join("$Year", "0", $i))
                md ".\$Year\$foldername"
            }
        else 
            {md ".\$Year\$Year$i"}
    }

}
            
            

       

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.