Используйте это для преобразования rtf в docx:
Function Convert-Dir($path){
$Files=Get-ChildItem "$($path)\*.docx" -Recurse
$Word=New-Object –ComObject WORD.APPLICATION
foreach ($File in $Files) {
# open a Word document, filename from the directory
$Doc=$Word.Documents.Open($File.fullname)
# Swap out DOCX with PDF in the Filename
$Name=($Doc.Fullname).replace("docx","doc")
if (Test-Path $Name){
} else {
# Save this File as a PDF in Word 2010/2013
Write-Host $Name
$Doc.saveas([ref] $Name, [ref] 0)
$Doc.close()
}
}
$Files=Get-ChildItem "$($path)\*.rtf" -Recurse
$Word=New-Object –ComObject WORD.APPLICATION
foreach ($File in $Files) {
# open a Word document, filename from the directory
$Doc=$Word.Documents.Open($File.fullname)
# Swap out DOCX with PDF in the Filename
$Name=($Doc.Fullname).replace("rtf","doc")
if (Test-Path $Name){
} else {
# Save this File as a PDF in Word 2010/2013
Write-Host $Name
$Doc.saveas([ref] $Name, [ref] 0)
$Doc.close()
}
}
}
Convert-Dir "RtfFilePath";
Код и атрибуция: https://gist.github.com/rensatsu/0a66a65c3a508ecfd491#file -rtfdocxtodo c -ps1