Open all files of type in subdirectories

Hi all,

I feel like this is close but falling down at import. I had a look at other answers for similar questions couldn’t quite get it.

path = str('lots of folders up to\\03 Design Supplied')
dwg = 'dwg'

def finddwgsinpath(path):
    for path, subdirs, files in os.walk(path):
        for name in files:
            if dwg in name:
                dwgpath = os.path.join(path, name)
                rs.Command("_-Import "+ dwgpath + " Enter",False)
                rs.Command("_Pause")
                print('imported...', dwgpath)
finddwgsinpath(path)

Thanks!

make sure you have your paths enclosed in double quotes:

rs.Command("_-Import \""+ dwgpath + "\" Enter",False)

thank you!