source
%获取子文件夹
dirList = dir(strPath);
isSubDir = [dirList(:).isdir]; %# returns logical vector
nameFolds = {
dirList(isSubDir).name}';
nameFolds(ismember(nameFolds,{
'.','..'})) = [];
nSubDir=length(nameFolds);
fileList=dir(fullfile(strcat(strPath,nameFolds{
1},'\*.avi'))); %取第一个文件夹
nFile=length(fileList);
1. The dir function
files=dir(FilePath)
Function: Display the files and folders in the FilePath directory
2. Fullfile function
f=fullfile('dir1', 'dir2', ..., 'filename')
Function: Use the information of each part of the file to create and synthesize the complete file path, the return value is a path, generally used with dir
Instance
>> FilePath = 'D:\study\dataset';
files = dir(fullfile(FilePath, '\*.xls'));
Return D:\study\dataset
all files in the .xls at the end of the path