$posts = gci ./ -filter *.md

$posts | % {
    $filename = $_.Name
    $parts = $filename.split("-")
    $year = $parts[0]
    $month = $parts[1]
    $day = $parts[2]

    $filename = $filename -replace "$year-$month-$day-",""
    $newDir = "./$year/$month/$day"

    new-item $newDir -itemtype directory -ErrorAction SilentlyContinue

    move-item $_.FullName "$newDir/$filename"
}