nextfile
Class: matlab.io.datastore.DsFileSet
Namespace: matlab.io.datastore
Information on next file or file chunk
Syntax
fileInfo = nextfile(fs)
Description
returns the information on the next file available in the file set object
fileInfo
= nextfile(fs
)fs
. Subsequent calls to the nextfile
function
continue reading from the endpoint of the previous call.
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
nextfile
method returns an error if no more files exist in the file-set objectfs
. To avoid this error, usenextfile
along withhasfile
andreset
. Thehasfile
method checks if files still remain in the file-set object, while thereset
method 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