%%%10.22.20 script to see which files are corrupted

% path='D:\4100_2020feb07\pansharpen\UTM_8N_Canada';
path='D:\4138_2020feb28\pansharpen';

files_feb28_all=dir(fullfile(path,'*pansh.tif'));

files=files_feb28_all;

q=size(files,1);

% corruptFiles=NaN(q,1);

for ii=1:q
    ii
    
    Stats(ii).name=files(ii).name(1:19);
    Stats(ii).Gbytes=files(ii).bytes./1e9;
    
    try img=imread(fullfile(files(ii).folder,files(ii).name),'PixelRegion',{[10000,10100],[10000,10100]});
        Stats(ii).corrupt=0;
    catch
        Stats(ii).corrupt=1;
    end

    clear img name1 size1
end
clear ii q

% corruptFiles_feb07_all=corruptFiles;
Stats_feb28_all=Stats;

clear files q corruptFiles Stats

corr=extractfield(Stats_feb28_all,'corrupt');
findCorr=find(corr==1)';
names=extractfield(Stats_feb28_all,'name');
nameCorrupt_feb28=names(findCorr)';

clear corr findCorr names

