Inkscape for bulk SVG conversion

I have a Windows machine with Cygwin on it.

It has a Windows install of Inkscape in (in Cygwin notation):

/cygdrive/c/Program Files/Inkscape/bin/inkscape.exe

So Cygwin gives me all the useful Linux/UNIX command line tools, and the one that we’re going to work with now is find.

I can see a list of all my SVG files, after I cd to the parent directory.

I can see what PNG files I already have:

$ find . -iname "*png" | more

I can see how to use Inkscape from the command line:

$ /cygdrive/c/Program\ Files/Inkscape/bin/inkscape.exe --help

And I see that I can ask it to export to a file type, and it will guess the output format based on the output file extension. Or I can specify a type and it will use the old file name with a new extension:

$ /cygdrive/c/Program\ Files/Inkscape/bin/inkscape.exe --export-dpi=72 --export-type=png filename.svg

So we can use find to walk the file hierarchy and inkscape to convert things when we find them.

$ find /path/to/parent/folder -name "*.svg" -exec /cygdrive/c/Program\ Files/Inkscape/bin/inkscape.exe --export-dpi=72 --export-type=png {} \;

Various command line switches can be used to tune the results.

Having said that, the non-native (Cairo) import into SVG seems to work better than the native one.

Switch

Author: Darren

I'm a scientist by training, currently working as a writer, trainer and editor.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.