Created
October 24, 2019 01:38
-
-
Save dance2die/03f0a49279d0e64b557940c642f01825 to your computer and use it in GitHub Desktop.
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
ls | % { | |
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_split?view=powershell-6 | |
$parsed = $_.Name -split '(\d{4})-(\d{2})-(\d{2})-(.*)' | |
$year = $parsed[1]; | |
$month = $parsed[2]; | |
$day = $parsed[3]; | |
$name = $parsed[4]; | |
$newDir = "$year/$month/$day"; | |
# Create a new directory matching the folder name. | |
# https://social.technet.microsoft.com/Forums/office/en-US/98232ee2-846c-4f49-9284-95d28dc5b2cb/recursively-create-directories?forum=winserverpowershell | |
new-item $newDir -ItemType Directory | |
# New File name without date prefix and with .mdx extension | |
$newFile = [IO.Path]::ChangeExtension("$newDir/$name", ".mdx") | |
Write-output $newFile | |
Copy-Item $_.Name $newFile | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment