Search folder with specific string within the subfolders and display the full name of the folder searched.
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have tried to build a basic code first in searching the folder with '_2D_MDE_TI_' within the subfolder. I've got the correct number of files that have this specific string on it but I can't display the full folder name of the target folder.
The whole folder name is something like ''20170906-50--2C_2D_MDE_TI_240''
Next, I tried using for loop to loop through 300+ folder and save both with and without specific string of the searched foldername, but I'm not sure how I suppose to write it.
The purpose is to check if the subfolders contain this type of folders,
Appreciate it if someone could help me with this.
Thank you
folder = 'C:\Users\Asian Cardiac Lab\Desktop\dicom';
maininfo = dir(fullfile(folder));
maininfo(~[maininfo.isdir]) = []; %remove non-directories
tf = ismember( {maininfo.name}, {'.', '..'});
maininfo(tf) = []; %remove current and parent directory.
subdirinfo = dir(fullfile(maininfo.name));
subdirinfo(~[subdirinfo.isdir]) = []; %remove non-directories
tf = ismember( {subdirinfo.name}, {'.', '..'});
subdirinfo(tf) = []; %remove current and parent directory.
a = regexp({subdirinfo.name},'_2D_MDE_TI_','match')
len = length(find(~cellfun(@isempty,a)))
a = [a{:}]
% answer that show regarding the code
Columns 1 through 12
{} {} {} {} {} {} {} {} {} {} {} {1x1 cell}
Columns 13 through 18
{1x1 cell} {1x1 cell} {1x1 cell} {1x1 cell} {1x1 cell} {1x1 cell}
Columns 19 through 20
{1x1 cell} {}
len =
8
a =
Columns 1 through 5
'_2D_MDE_TI_' '_2D_MDE_TI_' '_2D_MDE_TI_' '_2D_MDE_TI_' '_2D_MDE_TI_'
Columns 6 through 8
'_2D_MDE_TI_' '_2D_MDE_TI_' '_2D_MDE_TI_'
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!