Using regexpressions with 'dir' function
이전 댓글 표시
Hi, I have a folder (MainFolder) that contains other subfolders (Subfolder1, Subfolder2, Subfolder3, ....). Each of those subfolders contain different png images. The format of the name of those images is 'somerandomnameOD1.png' or 'somerandomnameOS1.png'. The last number of the names varies from 1 to 6.
I am trying to use dir function with some regexpressions to extract the path of all those images that end with a pattern like 'OD' or 'OS' followed by the number 1, 2 or 6 (OD1, OD2, OD6, OS1, OS2, OS6) from all the subfolders within the 'MainFolder':
a=dir('C:\folder\folder2\Desktop\MainFolder\**/*O(D|S) (1|2|3).png'));
But the result is an empty struct.
I know I can simply use this:
a=dir('C:\folder\folder2\Desktop\MainFolder\**/*.png'));
and then filter that structure for the names that I need.
But I woudl like to know if it is possible to use reg expressions with a 'dir' function.
Thanks.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!