Using wildcards for Windows command line batch convert

Trying to use following command line in Windows 10 x64 command prompt:

“C:\Program Files\LibreOffice\program\soffice” --convert-to “txt:Text” *.docx

But getting error:

Error: source file could not be loaded

Tried changing command line to:

“C:\Program Files\LibreOffice\program\soffice” --convert-to “txt:Text” “2019-12-20 18_32_25 - ZDA - [1] Winter Dance Party 2019-12-28.pdf.b64.*.docx”

But same error. If I issue the command with a complete filename, it works on that file. I have seen examples of wildcard * being used to specify multiple files on the command line here in these forums, and in the LibreOffice help file. What am I doing wrong?

Mike Kaganski: Based on suggested code at the link you provided, I successfully used this:

for %f in ("*.docx") do “C:\Program Files\LibreOffice\program\soffice.bin” --convert-to “txt:Text” “%f”

Thank you. Still confused, though, on why a standard wildcard that’s been used for such things in Windows and MS-DOS for years doesn’t work in this particular situation.

Alex Kemp: In my first example above, *.docx is not surrounded by quotes, but still didn’t work.

In *nix, it’s shell that handles the wildcards. So, when you issue the command soffice *.docx, the shell that interprets the command expands the *.docx into 1.docx 2.docx 3.docx ..., and then calls soffice with that modified command line. The tools on *nix are not expected themselves to do any wildcard processing, they get it uniformly from shell.

On Windows, there’s that convention about wildcards, too; but there’s no shell pre-processing of the command line, and it’s the tool’s duty to handle them. Each tool does it itself, hawing own bugs and differences in e.g. hidden files handling in the expansion.

LibreOffice does not do any such processing, and expects the *nix-way of processing them. Thus, that doesn’t work on Windows.

It’s the inner mechanism of the difference. It’s tdf#48413.

Possibly: move the wildcard out of the quote-marks. So that it ends:


(I no longer have a copy of Windows before me to test for you)