Powershell: How to batch-convert Word files to PDF

Kurz gegoogelt und, wie so oft, die Antwort bei stackoverflow gefunden:

$documents_path = 'c:\doc2pdf'

$word_app = New-Object -ComObject Word.Application

# This filter will find .doc as well as .docx documents
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()

Quelle: https://stackoverflow.com/questions/16534292/basic-powershell-batch-convert-word-docx-to-pdf

Schreibe einen Kommentar