Date: prev next · Thread: first prev next last
2014 Archives by date, by thread · List index


Paul,

I feel like I'm almost there.

This may be outside the scope of this listserv, so I hope it is ok if I ask
this question.

The example given on
http://ask.libreoffice.org/en/question/2641/convert-to-command-line-parameter/
is as follows:

set path=%path%;C:\Program Files (x86)\LibreOffice 4\programfor %f in
(*.odg) do (
    soffice.exe --headless --convert-to pdf --outdir "C:\tmp" %f)


I do not know what language this is.  I do have some programming
experience, mostly in Perl, years ago (I forgot most of it...I'm rusty.  I
took C in college too but can't remember that either).  I've also done some
programming tutorials on Codecademy.com in Javascript, Python, jQuery,
HTML, CSS.

Here is my understanding of the code.  The writer first adds the
LibreOffice directory to the "path" environment variable.  Path is a
Windows operating system environment variable containing special
directories.  These directories tell Windows where to look for executable
files. Thus, any executable file that is in a folder, that is in the "path"
environment variable, can be run at the command prompt by simply typing its
name, without having to specify exactly where it is.  For example, typing
"soffice" (just the executable file's name) at the command prompt, instead
of "C:\Program Files (x86)\LibreOffice 4\program", will open soffice.exe.
It makes using the command line simpler and quicker.
In that way, the writer can simply start his code in the for loop with
"soffice".

What I don't understand is, how does the batch file know where to look for
the input files?  All that the batch file is given is an iterator variable
%f.  This iterator variable ideally takes on the values, one by one, of the
file names that end with .odg (in this case).  But how does the command
line know where to look to find those .odg files to convert in the first
place?

Thanks again, and sorry for so many questions.  I just feel so close, and
I've been working on this problem for days.
joe



On Thu, Apr 10, 2014 at 7:38 PM, Paul <paulsteyn1@afrihost.co.za> wrote:

Hi Joe,

Glad this got you started in the right direction. See inline for more...


On Thu, 10 Apr 2014 19:06:51 -0500
Joe B <paperbag76@gmail.com> 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...

Also, and most importantly, it appears to me that this command cannot
run in batch mode?  In the example given at the website I linked
above, the format of the command only takes one file at a time.  How
would it process multiple files at a time, if the final parameter is
a file name?  Wouldn't it need to be a directory name?
Well, no. It does take a filename, but according to the help you can use
wildcard characters, like in my example in the previous mail. So for
example to convert all the ".htm" files in a directory, you would use
"*.htm" as the file name, like so

soffice.exe --convert-to pdf *.htm

And, as commented before, you might want to give an output
directory with "--outdir", and might need to specify "--headless".

Note that according to the URL you gave, not using --headless will open
a blank LO window and not finish until you close that, and using
--headless when LO is already open will *silently do nothing*.

Also, according to the URL you gave, wildcard characters don't
actually work in the filename, so you have to use a batch script. An
example is given in the second last answer. Note that the example given
is supposed to be run straight from the command line, but could also be
placed in a batch file, although you may have to make the change
recommended in the answer, and you will *have* to change the "(*.odg)"
to "(*.htm)" in your case. To make a batch file, simply copy and
paste the commands into a plain text file, save it, then rename
it to change the ".txt" extension to ".bat". Then you should be able to
run the file (either by double clicking or from the command line), and
it will process all the .htm files in the same directory as the batch
file.

You could also write the same batch file in python, as I seem to recall
you stating you were at least a little familiar with python.

You'll have to experiment to see if you can use wildcard characters or
not, as they would be by far the easiest solution. And if they don't
work, a bug should *definitely* be filed.

Hope this gets you all the way to a solution.

Paul

--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems?
http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be
deleted



-- 
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.