How to import multiple svg files at once to the layer that I can edit

I saw this program.
I want to import multiple svg files at once to the layer that I can edit.
I can’t work like this.

pickpath = GetFolder("Please choose a folder with images")
pickextension = "svg"
masterID = Glyphs.font.masters[Glyphs.font.masterIndex].id
for glyph in Glyphs.font.glyphs:
    if glyph.unicode:
        print glyph.unicode
        layer = glyph.layers[masterID]
        layer.path = GSPath(pickpath + glyph.unicode + '.' + pickextension)  #What should be expressed here?

more like this:

GSSVGtoPath = NSClassFromString("GSSVGtoPath")
path = "/path/to/file.svg"
Importer = GSSVGtoPath.alloc().init()
Importer.readFile_toLayer_error_(NSURL.fileURLWithPath_(path), Layer, None)

That’s great! Thank you very much!:star_struck::star_struck:

I also want to use multiple svg’s on a single svg layer, but I’m having trouble using this code, as it’s my first time working with the “makro window”.
I replaced the generic path with the path to the svg I want to use, is there something else I need to replace?
I get:

Traceback (most recent call last):
  File "<macro>", line 4, in <module>
  ValueError: NSInvalidArgumentException - -[NSXMLNode stringValueForName:]: unrecognized selector sent to instance 0x600006643da0

Are you sure it’s a valid SVG? This error says that it cannot read the XML.

Thank you for your quick reply!
I was quite sure, It’s a black to white gradient created with Adobe Illustrator:

<svg xmlns="" xmlns:xlink="" viewBox="0 0 301 302">
      .a {
        fill: url(#a);
    <linearGradient id="a" data-name="v" x1="-0.5" y1="150" x2="301.5" y2="150" gradientTransform="translate(0.5 301.5) rotate(-90)" gradientUnits="userSpaceOnUse">
      <stop offset="0" stop-color="#fff"/>
      <stop offset="1"/>
  <rect class="a" width="301" height="302"/>


What makes an SVG invalid to be used within Glyphs?

The script works fine for me. What versions of Glyphs and macOS of you have?

tried it on glyphs Version 2.6.7 (1357)
macOS Big Sur 11.6

This particular has a line that seems odd. Remove preserveAspectRatio="none".