List all files in a directory given a regular expression / a set of extensions (Matlab)

后端 未结 3 1449
花落未央
花落未央 2020-12-06 07:28

I have a regular expression defining the filenames of interest. What is the best way to list all files in a directory that match this condition?

My attempt at this i

3条回答
  •  温柔的废话
    2020-12-06 08:00

    My loop variation:

    ext = [".doc",".docx",".rtf"];
    f = [];
    for e = ext
        f = [f;dir(char(strcat('**/*',e)))];
    end
    f = f([f.isdir] == 0);
    

提交回复
热议问题