我正在尝试在我的脚本中标识某个子目录模式。我得到的问题是目录没有被正确识别。下面是我当前的代码:
parentDir = '/data/home1/fL/user/path/to/subdirectories/'
totalFiles = subdir(fullfile(parentDir, '/*.7'));
name = {totalFiles.name}' % cells containing directories with the .7 ext this is a 118*1 cell
numTotalFiles=length(name); % =118
% this section is supposed to sort through all the subdirectories paths that
% have the pattern A_G/*.7 and p_G/*7 in their pathname but fails to do so.
for i=1:numTotalFiles
patternsplit = totalFiles(i).name
str = ["*/A_G/*.7","*/p_G/*.7"]
ptrn = ["A_G","p_G"]
pattern = patternsplit(startsWith(str,ptrn))
found = pattern
end
我希望输出是包含模式A_G/*.7
和p_G/*.7
的子目录列表。我认为这可能是一个44x1的单元格,其中包含具有这些模式的所有子目录名称。
https://stackoverflow.com/questions/56728336
复制相似问题