assuming that you want to go inside each sub-directory and read the images
Root_directory='The directory location';
sub_directories=dir(Root_directory);
sub_directories(1,2)=[]; % to remove . and ..
for sub_dir_index=1:length(sub_directories)
images=dir(fullfile(Root_directory,sub_directories(sub_dir_index).name));
the rest of your code
end