I need to skip some specific files in different sub-folders. So I tried by line "if filename" in the snippet that if the filename not contains raw, info, do some operations, but it doesn't work. I really appreciate if someone can point me in the right direction how can I skip these filenames which does have specific character like "raw" or "info."..
input_dirName = dir('D:\Neda\Pytorch\CAMUS\training\');
Output_dirName = 'D:\Neda\Pytorch\CAMUS\data\';
GT_dirName = 'D:\Neda\Pytorch\CAMUS\GT\';
dirName = 'D:\Neda\Pytorch\CAMUS\training\';
fileList = SureScan_getAllFiles(dirName);
foldername = fullfile({input_dirName.folder}, {input_dirName.name});
foldername = foldername(3:end);
for k = 1:length(fileList)-50
filename = fileList{k};
if filename ~= contains(filename,'raw') | filename ~= contains(filename,'Info_') | filename ~= contains(filename,'sequence.mhd')| filename ~=contains(filename,'_sequence')
% do some operation
end
end
The output of contains
is either true
or false
and hence it will never be equal to any filename.
To skip filenames that have any of 'raw'
, 'Info_'
, 'sequence.mhd'
or '_sequence'
, use:
if ~contains(filename, {'raw', 'Info_', 'sequence.mhd', '_sequence'})
%do some operation
end