MATLAB: Open files with certain file size

file sizeopen file

Hi I have hundreds of files with a similar name. I can open them all with the following code:
% Open the HDF5 File.
for k = 1:365
FILE_NAME = sprintf('MLS-Aura_L2GP-O3_v04-20-c01_2006d%03d.SUB.he5',k);
file_id = H5F.open(FILE_NAME, 'H5F_ACC_RDONLY', 'H5P_DEFAULT');
end
now I only want to open files when the file size is greater than 37 KB. How do I do that ?

Best Answer

files = dir('your file extension') ;
% loop for each file
for i = 1:length(files)
if files(i).bytes*1000 > 37 % if file size is > 37 do what you want
filename = files(i).name ;
disp(filename)
%open your file do what you want
end
end