Open files from multiple subdirectories


I’m trying to open files with extension .nrrd from multiple subfolders. So far I only got to open one file at a time. This is the working version:
dir_path = qt.QFileDialog.getOpenFileName(self.parent, ‘Open file’, ‘D:\SlicerTest\THA’, “All Files (*.nrrd)”)
dir_path = dir_path.replace("\", “/”)

The other version that is not working (the files with my .nrrd extension are not even visible) looks as follows:
dir_path = qt.QFileDialog.getExistingDirectory(None, ‘Open folder’, ‘/home/’, qt.QFileDialog.ShowDirsOnly)
Also, I would like to select the folders that I want to open, e.g. from 89 to 95.

I would appreciate any feedback.

Have a look at the utility functions to open files via python, starting here:

You can use python’s directory iteration tool to get the file or directory names, and then test the filename to make your selection, see: