function isOkSSIDX = CheckS2Directory(S2Dir);
%function isOkSSIDX = CheckS2Directory(S2Dir);
%
%looks through an S2 directory, and returns a vector of length 3547, the number of imgs in the SSDB.
%isOkSSIDX(i) = 1 iff the S2 representation of this image at least has all the necessary files.

isOkSSIDX = zeros(3547,1);
%isOkSSIDX(1:135) = 1;
Range = 1:3547;
%Range = 1442;
L = length(Range);
t = cputime;
n = 0;
for i = Range
   e = cputime - t;
   fprintf('%d of %d costs %d seconds: ', i, L, floor(e));
   D = fullfile(S2Dir, sprintf('%.5d',i));
   [isOkSSIDX(i)] = exist_JPEGMatrix(D, 'C2_Data');
   n=n+1;
   cpe = e / n;
   fprintf('Cost Per Each = %f sec:  ', cpe);
   fprintf('Time Remaining = %f sec:  \r', cpe * (L - n));
end
fprintf('\n');