#!/usr/bin/env pwsh
# usage: creates HTML files for each *.md file
#        stop with Ctrl+C
#        requirement: Pandoc installation
while($true) {
    foreach($mdfile in Get-ChildItem -Path *.md) {
        $htmlfile = $mdfile.FullName.Replace(".md", ".html")
        if(!(Test-Path $htmlfile) -or 
            ($mdfile.LastWriteTimeUtc -gt 
             (Get-Item $htmlfile).LastWriteTimeUtc)) 
        {
            Write-Host $mdfile.Name
            # change path here
            C:\path\to\pandoc.exe $mdfile.FullName -o $htmlfile
        }
    }
    Start-Sleep -Seconds 1
}