Ask Your Question
2

batch conversion with unoconv in Windows [closed]

asked 2012-07-25 02:37:48 +0100

MikeW gravatar image

updated 2015-10-23 13:58:35 +0100

Alex Kemp gravatar image

I tried to use unoconv to convert all odg documents in a folder to svg but it just dies with "cannot find file". Is there something I am missing to able to do this?

python unoconv.py -f svg *.odg
unoconv: file '*.odg' does not exist.
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2015-10-23 14:00:00.234153

Comments

It looks like the '*' (asterisk) character was removed from my post somehow. I attempted to use wildcards with LibreOffice directly and then with unoconv but neither work in a Windows environment (specifically Win7 though I doubt that makes a difference).

MikeW gravatar imageMikeW ( 2012-07-30 15:52:19 +0100 )edit

Hi @MikeW, I've updated the formatting in your post so that the asterisks are visible in the output.

qubit gravatar imagequbit ( 2013-01-29 10:10:38 +0100 )edit

3 Answers

Sort by » oldest newest most voted
2

answered 2012-08-08 17:25:52 +0100

MikeW gravatar image

updated 2013-02-24 21:19:21 +0100

qubit gravatar image

It appears that Windows understands wildcards in a different way than Linux and so LibreOffice or even Python cannot utilize ("*.odg") in Windows without using the "glob" module. (It seems that Python's implementation of OS recognizes *.odg as a literal filename in Windows instead of a wildcard).

To solve this, I had to write a wrapper like the following:

matches = []
for root, dirnames, filenames in os.walk(os.getcwd()):
  for filename in fnmatch.filter(filenames, '*.odg'):
      matches.append(os.path.join(root, filename))

os.system("unoconv.py -f svg " + " ".join(matches))

I hope that helps others who encounter this same problem.

edit flag offensive delete link more

Comments

Makes sense. On Unix it is the shell that expands wildcards not the tool, on Windows it's probably the tool that expands wildcards and we may have to improve unoconv to also accept wildcards. So it's not exactly a bug. If you care about this functionality in unoconv, feel free to open an issue !

dag gravatar imagedag ( 2012-08-31 14:36:33 +0100 )edit
2

answered 2012-07-26 05:34:18 +0100

qubit gravatar image

I'm not sure about the unoconv.py script (is that file provided by LO?), but here's how I convert Draw (odg) files to svg on the command line:

libreoffice -v --headless --convert-to svg test.odg

Note that if you already have LO running, that command will probably quit before doing any conversion for you. If you want to convert all odg files in a given directory, you can use a wildcard in your invocation like so:

libreoffice -v --headless --convert-to svg *.odg

edit flag offensive delete link more
2

answered 2012-07-27 14:56:30 +0100

dag gravatar image

updated 2012-07-27 14:57:07 +0100

I don't know what exactly you are doing, what version of unoconv you are running, or why it failed. But it works perfectly on my system:

[dag@moria ~]$ unoconv -f svg test.odg 
[dag@moria ~]$ ls *.svg
test.svg
[dag@moria ~]$ file test.svg 
test.svg: SVG Scalable Vector Graphics image

It also works using wildcards:

[dag@moria ~]$ rm -f test.svg
[dag@moria ~]$ unoconv -f svg *.odg 
[dag@moria ~]$ ls *.svg
test.svg
[dag@moria ~]$ file test.svg 
test.svg: SVG Scalable Vector Graphics image

I am using unoconv v0.5 and LibreOffice 3.4.5, so it should work !

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2012-07-25 02:37:48 +0100

Seen: 5,918 times

Last updated: Feb 24 '13