I want to delete *.xlsx files if they meet a certain criteria. However when a file is deleted based on the first if statement it continues to try and look though the files for the other criteria. How can bypass the remaining if statements and continue onto the next file if one of the if statements are satisfied?
excel_xlsx=dir('*.xlsx'); % list of the files
for i=1:length(excel_xlsx) [~,file]=xlsfinfo(excel_xlsx(i).name); L=length(file); [~,txt]=xlsread(excel_xlsx(i).name,L,'B2'); % read the text
if strcmp(txt,'Number:') delete(excel_xlsx(i).name) else [~,txt]=xlsread(excel_xlsx(i).name,1,'B3'); % read the text strcmp(txt,'PROGRAM') delete(excel_xlsx(i).name) else [~,txt]=xlsread(excel_xlsx(i).name,1,'A10'); % read the text strcmp(txt,'UPPER') delete(excel_xlsx(i).name) else [~,txt]=xlsread(excel_xlsx(i).name,1,'A2'); % read the text strcmp(txt,'Effect') [~,sheets] = xlsfinfo(excel_xlsx(i).name); xlsprotect(excel_xlsx(i).name,'unprotect_sheet',sheets{1,1}); xlswrite(excel_xlsx(i).name,' ',1,'F1'); xlswrite(excel_xlsx(i).name,' ',1,'F2'); xlswrite(excel_xlsx(i).name,' ',1,'F3'); xlswrite(excel_xlsx(i).name,' ',1,'E1'); xlswrite(excel_xlsx(i).name,' ',1,'E2'); xlswrite(excel_xlsx(i).name,' ',1,'E3'); xlswrite(excel_xlsx(i).name,' ',1,'E4'); endend
Best Answer