MATLAB uses the Dir function to obtain all subfolders and files in the specified folder and store them in an array of object structures.
The dir function can be called.
Dir ('.') lists all subfolders and files in the current directory
Dir ('G: \ MATLAB ') lists all subfolders and files in the specified directory
Dir ('*. M') lists the folders and files in the current directory that match the regular expression.
The result is that each element in the struct array is a struct in the following format.
Name -- filename
Date -- modification date
Bytes -- number of bytes allocated to the file
Isdir -- 1 If name is a directory and 0 if not
Datenum -- modification date as a MATLAB serial date number
They are the file name, modification date, size, whether it is a directory, and the specific modification date of Matlab.
The file name can be extracted for reading and saving.