Batch convert SVG to PNG with Inkscape command line

I recently was looking for a way to batch convert a bunch of SVG vector files into PNG raster graphics. The usual suspect Imagemagick didn’t help me in the case of a vector graphics.

Looking for a solution I came across a post from forger on ubuntuforums.org. He uses the command line of the famous Inkscape vector graphics suite, so make sure inkscape is installed. Open up a terminal and type in the following two commands.

$ cd your-directory-with-the-svgs/
$ for i in *; do inkscape $i --export-png=`echo $i | sed -e 's/svg$/png/'`; done
This entry was posted in Planet, Ubuntu and tagged , , , , , , , , . Bookmark the permalink.

6 Responses to Batch convert SVG to PNG with Inkscape command line

  1. wijaya says:

    The ‘g$’ in ‘s/svg$/png/’ is missing. As it is, Inkscape will overwrite the SVG files.

  2. Brian says:

    Awesome tip thanks!!!

  3. Rutvik Karve says:

    Made a slight change to handle filenames with spaces –

    for i in *; do inkscape “$i” –export-png=”`echo “$i” | sed -e ‘s/svg$/png/’`”; done

  4. Pingback: Good application to render or convert SVG files to other file formats [ANSWERED] - Tech ABC to XYZ

  5. This is such an elegant method. Thank you!

Leave a comment