title: Batch export and ungroup SVG to PNGs of each layer/group
body: <p>I have a folder of SVG images and I was looking at how I might be able to save each layer (group) of the SVG to a separate PNG file. I was working in Matlab, but I haven't seen any method that works for SVGs. I looked at a few external libraries, Batik being the main one, but I don't know enough XML to get this to work. I looked at Inkscape too, but its <a href="http://tavmjong.free.fr/INKSCAPE/MANUAL/html/CommandLine-Export.html" rel="nofollow noreferrer">export options</a> only seem to allow you to work with the entire rasterized image. I also looked at ImageMagick, but only found a layers method that seemed to make GIFs rather than the layers I want from the SVG.</p>
  
  <p>Update: realized I can use ImageMagick to save layers this way <code>convert image.svg[1] output.png</code>, I still don't know 1) how to batch ungroup the layers in the SVG (they're ungroupable for sure--I checked in Illustrator) and 2) count how many layers I have in each SVG so I can go through all the layers to save them individually.</p>