Richard Chopper
Richard Chopper

Reputation: 13

Batch convert wpd files to docx with LibreOffice

I'm trying to convert a bunch of wpd filed into docx with libreoffice, so far I have been able to achieve it but the resultant docx files are saved in just one folder (Ale) instead of Ale and its subdirectories, and what I want is for the docx files to be saved in the folder the wpd file are in. So far I have:

set path=%path%;"C:\Program Files (x86)\LibreOffice 5\program"
for /r %%f in (*.wpd) do (
soffice.exe -headless -convert-to docx:"MS Word 2007 XML" -outdir "S:\Temp\Ale" %%f)

Upvotes: 1

Views: 1367

Answers (1)

Jim K
Jim K

Reputation: 13790

Like @aschipfl said, go to the directory of each file and then do the conversion:

setlocal enableDelayedExpansion
set "path=%path%;C:\Program Files (x86)\LibreOffice 5\program"

for /r %%f in (*.wpd) do (
    pushd %%~dpf
    soffice.exe -headless -convert-to docx:"MS Word 2007 XML" "%%f"
    popd
)
endlocal

Upvotes: 0

Related Questions