I would like to scan a directory for .htm files and then generate hyperlinks to those .htm files and output the result to a new HTML document. What is the best way to achieve this?
So far I have this:
Get-ChildItem "C:\test1\*.htm" -Recurse -Force |
ConvertTo-Html -Fragment FullName, Name `
-PreContent '<html><head><title>Test</title></head><body>' `
-PostContent '</body></html>' |
% { $_ -replace '<th>.*</th>','<th>Files</th>' `
-replace '<td>(.*?)</td><td>(.*?)</td><td>(.*?)</td>',
'<td><a href="$1">$2</a> $3</td>'
} | Set-Content "C:\$env:COMPUTERNAME-$(Get-Date -f dd-MM-yyyy-hh-mm-ss).htm"