Untitled

 avatar
unknown
powershell
a year ago
403 B
9
Indexable
# Muhit - batch convert doc/docx to pdf

$documents_path = '<path>'

$word_app = New-Object -ComObject Word.Application

Get-ChildItem -Path $documents_path -Filter *.doc? | ForEach-Object {

    $document = $word_app.Documents.Open($_.FullName)

    $pdf_filename = "$($_.DirectoryName)\$($_.BaseName).pdf"

    $document.SaveAs([ref] $pdf_filename, [ref] 17)

    $document.Close()
}

$word_app.Quit()
Editor is loading...
Leave a Comment