pwsh -c "./doc2docx.ps1 -FolderPath ./target -Verbose"
param(
$FolderPath = "C:\Path\To\Your\Files",
[switch]$Verbose = $false
)
$FolderPath = Resolve-Path $FolderPath
$Word = New-Object -ComObject Word.Application
$Word.Visible = $false
$files = Get-ChildItem $folderPath -Filter *.doc
foreach ($file in $files) {
if ($Verbose) {
Write-Host "Processing file: $($file.FullName)"
}
$Doc = $Word.Documents.Open($file.FullName)
$Doc.SaveAs([ref] $file.FullName.Replace('.doc', '.docx'), [ref] 16)
$Doc.Close()
}
$Word.Quit()