1

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)
aschipfl
  • 33,626
  • 12
  • 54
  • 99

1 Answers1

0

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
Jim K
  • 12,824
  • 2
  • 22
  • 51
  • yeah I'll do that. Thanks – Richard Chopper Jul 19 '16 at 07:14
  • Except your script just worked and I didn't have to place the script in every directory, it worked from the first one. – Richard Chopper Jul 19 '16 at 07:17
  • Well, yes, what I meant by "go to the directory" is that the script goes to each directory by using `pushd`. Anyway, if it answered your question, then please [accept the answer](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work). – Jim K Jul 19 '16 at 08:21