nextfile
Class: matlab.io.datastore.DsFileSet
Namespace: matlab.io.datastore
Information on next file or file chunk
Syntax
fileInfo = nextfile(fs)
Description
Input Arguments
Output Arguments
Examples
Get File Information One File at a Time
Create a file-set object and get the file information iteratively, one file at a time.
Create a file-set object for all .mat files in the
demos
folder.
folder = fullfile(matlabroot,'toolbox','matlab','demos'); fs = matlab.io.datastore.DsFileSet(folder,... 'IncludeSubfolders',true,... 'FileExtensions','.mat');
Get the file information from the file-set object fs, one file
at a
time.
while hasfile(fs) file = nextfile(fs); end
Tips
The
nextfilemethod returns an error if no more files exist in the file-set objectfs. To avoid this error, usenextfilealong withhasfileandreset. Thehasfilemethod checks if files still remain in the file-set object, while theresetmethod resets the internal file pointer to the beginning of the file-set object.
Version History
Introduced in R2017b
See Also
matlab.io.datastore.FileSet | matlab.io.datastore.DsFileSet | hasfile | maxpartitions | partition | reset | resolve