Search code examples
matlabfile

MATLAB R2020b uiget to grab files of a certain type from multiple folders


I am using Matlab R2020b to process many .mat data files at once. Unfortunately, the hundreds of data files I received are organized in multiple folders - with each of the .mat files that I need in a separate folder within the parent directory.

I know how to use uigetfile to get multiple files from the same directory. I don't think uigetdir would work for this, as I am trying to choose multiple files of a certain type from different directories - not different directories themselves.

Is there a way to select every file with a certain extension, from multiple folders within a directory using uigetfile or uigetdir?


Solution

  • You should walk through a root folder which contains all the files you want to process. The following routines should help: dir ls regexp.

    But there are many other ways to implement this. Do not confine yourself to MATLAB:

    1. You can write a shell script to get the full path of all the files and then feed these paths to matlab. This option should work on both windows and linux.
    2. Use some file manager applications providing this ability. e.g. freecommander XE.