Find a better way to remove '.' and '..' in folder list function % listing = listing(3:end); idxvalid = cellfun(@(x) strcmp(x(1),'.'),{listing.name}); listing = listing(~idxvalid);