Files
Powershell-Scripts/Utility Scripts/Convert doc to docx.ps1
T

16 lines
636 B
PowerShell
Raw Normal View History

2025-08-05 14:48:38 +00:00
$Path = "C:\Temp\"
$Word_App = New-Object -ComObject Word.Application
$Format = [Microsoft.Office.Interop.Word.WdSaveFormat]::wdFormatXMLDocument
$List = Get-ChildItem -Path $Path -Recurse -File -Filter '*.doc' | Where-Object { $_.Name -match '.+\.doc$' }
Foreach ($Item in $List) {
if ($Item.Name -match '.+.doc$') {
$Document = $Word_App.Documents.Open($Item.FullName)
$Docx_Filename = "$($Item.DirectoryName)\$($Item.BaseName).docx"
$Document.SaveAs([ref]$docx_filename, [ref]$Format)
$Document.Close()
#Remove-Item -Path $Item.FullName -Force
}
}
$word_app.Quit()