Using LibreOffice on the command line to batch convert .htm files to .html files

Er, no: you cannot. Try it and see.

Brian Barker

I finally got the batch file to work.

My final code is:

for %%f in (*.htm) do (
"C:\Program Files (x86)\LibreOffice 4\program\soffice.exe" --headless
--convert-to html:"HTML" --outdir
"C:\Users\Joe\Clare\MCSLT\OutputHtmlFiles" %%f
)

In my batch file above, I had to use the absolute path of soffice.exe to get the batch file to work. I tried putting "C:\Program Files (x86)\LibreOffice 4\program\soffice.exe" in my %path% environment variable, so that I could simply call soffice.exe in the batch file, but this caused Firefox to crash on startup! What a bizarre problem.

It's no so bizarre: the PATH environment variable takes paths, not file names. If you'd put
C:\Program Files (x86)\LibreOffice 4\program
there - without the file name "soffice.exe" - it would have worked. When it finds just "soffice.exe" in your batch file, the system will search the appropriate directory (amongst others) to find it.

I have successfully modified the %path% variable before, by adding "C:\Python34" and had no problems.

Exactly: a path, not a file name.

Anyway...maybe someone is interested in this apparent conflict between soffice.exe in %path% and Firefox?

Putting a file name there instead of a path is likely to cause confusion ...

The important thing is, the batch script works ...

Good-oh! What you did was a perfectly acceptable alternative, of course.

I trust this helps.

Brian Barker

>>I'm not sure if you can use
>>cd c:
>
>Yes, you can use that to change directory.

Er, no: you cannot. Try it and see.

Er, actually, in the context of the question, you can. The question
as I understood it wasn't "can you use 'cd c:' to change directory", but
rather "can you use 'cd c:\docs' to change directory, or only cd
'docs'". Here's the full original context:

So on the command-line you would do something like

cd c:/Documents and Settings/Joe B/My Documents/html files

to get into the right folder and then run the batch file from there.
I'm not sure if you can use

cd c:

tbh, i think you have to skip the c: bit and plunge straight into the
rest of it

You're right that *on it's own* "cd c:" doesn't change directory, it
only shows the current directory of the C drive.

Funny quirk of the DOS system...

Paul

>>In sum: Does this mean that my .bat file would have to go into the
>>same windows directory as my input .htm files, in order to know
>>which ".htm" files it should use to create the glob?
>
>Yes, exactly.

Er, the answer to this - as you had previously explained - is
actually "No".

You're right, the answer should have been the same as the one I gave
to the next question:

Yes, unless you put "cd" commands in the batch file, or use a shortcut
to change the working directory.

Paul

Paul wrote:

This bug desperately needs to be fixed.

Yes, I agree. Should someone open a bug report, or is there one
already? Anybody know more about this? I haven't actually gotten as far
as registering an account for the bugtrack system before...

Looks like it was filed just over a week ago against LO 4.2.1.1 on Windows, and someone else sees it with LO 4.2.2.1:
   https://bugs.freedesktop.org/show_bug.cgi?id=76932

For what it's worth, with LO 4.0.4 on Windows, I find:
- The line about "--minimized" is not rendered correctly (only the lower half of the text is visible; other lines above and below are fine)
- The last visible line is the description of "--infilter"
- Long lines are cut off at the right side (descriptions of "--web" and "--infilter")
- There is no "Close" button within the dialog, but there is an "OK" button which is clear of other text and works
- Still no way to see the complete text though!

Mark.

Hi :slight_smile:
3 logicians went into a bar. The barman asked "do you all want a beer?"

The first says "dunno"
so the 2nd says "dunno" too
and that means the 3rd is able to say "Yes" because now he knows both the
others do too.

Being precisely logical can be fun but very confusing to everyone else!

I would definitely avoid putting a "cd" command directly into a batch file
because it drastically reduces the flexibility and could easily make a very
confusing muddle. On the other hand if that is the only folder you ever
want it to run in then it might be a good idea. However the way you have
done it is better.

Paul's point about copying the batch file into a common folder (such as
c:/utils errr should that be a \?) and then using Brian's point to add
that folder to path thing sounds like the best plan to me. That way you
are more likely to be able to find the batch file if you ever need it
again.

There has been loads of interesting detail in this thread! ~:) Many thanks
Paul and Brian, and Joe too. Some i had just forgotten or not really
noticed but a lot of it was new.

Of course i am on Gnu&Linux now so my command-line is often colour-coded
and allows tab-complete so a lot of the command-line stuff is MUCH easier
to do without taking much notice of what i'm actually entering.

When Win95 came out i didn't trust any of the buttons to do exactly what i
wanted and nothing extra so i tended to carry on using my own batch files
instead of stuff like copy&paste, plus my batch files seemed to do it
faster with less whirring. I think Win95 didn't have a "move" or
"drag&drop" so even my simple batch-files gave more functionality. Plus i
was already tired of "log off" so i had batch files that responded to being
told to "bugger off" or "off".

Regards from
Tom :slight_smile:

Heh, thanks, I always wondered what the gag was meant to be.

Given the barman's question, I always figured the first one's answer
should be:

"No, thanks, I'd like one just for me."

Paul

Hi :slight_smile:
That's the common-sense answer.

The logicians were too caught up in following the instructions too
accurately and truthfully, in much the same away that you and Brian were.
It was amusing to see a real-world example :slight_smile: (and i'm guessing that's
why Brian said it)
Regards from
Tom :slight_smile:

Grrr, i wish i could take back my last post!