%Loop over all samples in the database %The name of the directory with the database dirname = 'D:\database_directory\'; %The suffix with the file format suffix = '.png'; %Open the file with the file names. fid=fopen([dirname 'listnames.txt'],'rt'); maxlistlen=0; ni=0; while ~feof(fid) ni=ni+1; sn=fgetl(fid); listlen(ni)=findstr(sn,';')-1; listnum(ni)=sscanf(sn(findstr(sn,';')+1:length(sn)),'%d'); if maxlistlen