E=mc2
asked on
Using powershell to convert .txt file to .html
I would like to use a Powershell script to convert a text file to html
Can this be done?
Can this be done?
ASKER
$content = cat yourfile.txt -Raw
$title = 'My HTML'
$html = @"
<html>
<head><title>$title</title></head>
<body>
<pre>$content</pre>
</body>
</html>
"@
$html | Out-File 'file.html'
$title = 'My HTML'
$html = @"
<html>
<head><title>$title</title></head>
<body>
<pre>$content</pre>
</body>
</html>
"@
$html | Out-File 'file.html'
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Rename-Item
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/rename-item?view=powershell-7.1if you mean to convert the text file content accordingly, then you need to provide at least some requirements on this.