MATLAB: How to list files in the directory pwd How do i list file with certain prefix for instance file that include 'Data' in the directory and of certain type for instance only excel file ('.xlsx') Best Answer https://www.mathworks.com/help/matlab/ref/dir.htmlD = 'absolute/relative path to where the files are saved';S = dir(fullfile(D,'Data*.xlsx')) Related SolutionsMATLAB: List only top directories I found a dirty workaround, but I welcome if there are any more efficient script to replace my method, thansk start_path = fullfile(matlabroot, 'C:\Users\'); % Ask user to confirm or change. topLevelFolder = uigetdir(start_path);list=dir(topLevelFolder); %get info of files/folders in current directorydirnames={list([list.isdir]).name};dirnames=dirnames(~(strcmp('.',dirnames)|strcmp('..',dirnames)));for i = 1:length (dirnames)s (i) = strcat (topLevelFolder,'\', dirnames (i))end MATLAB: Fullfile to contain multiply file extension Try:filePatternCSV = fullfile(handles.sourceFolder, '*.csv'); csvFiles = dir(filePatternCSV); filePatternXLS = fullfile(handles.sourceFolder, '*.xls'); xlsFiles = dir(filePatternXLS);filePatternODS = fullfile(handles.sourceFolder, '*.ods'); odsFiles = dir(filePatternODS);allFiles= vertcat(csvFiles,xlsFiles,odsFiles); Related QuestionParsing integers from directory listDir(cd)Listing folders in directory with specific strings
Best Answer