wildcard in dir command - single char

16 ビュー (過去 30 日間)
barak ostraich
barak ostraich 2019 年 7 月 23 日
コメント済み: Walter Roberson 2020 年 9 月 30 日
how can i search files of pattern aaa0.... aaa1......
without finding the file aaa (without number)
at system dir command its " dir aaa? "
but i cant run this in matlab
i need the results as structure so i cant use system command
  1 件のコメント
Alex Mcaulley
Alex Mcaulley 2019 年 7 月 23 日

サインインしてコメントする。

回答 (1 件)

Stephen23
Stephen23 2019 年 7 月 23 日
編集済み: Stephen23 2019 年 7 月 23 日
dir does not support single-character wildcards.
You could remove the superfluous filenames afterwards, e.g.:
>> S = dir('aaa*.txt');
>> S.name
ans = aaa.txt
ans = aaa0.txt
ans = aaa1.txt
>> C = {S.name};
>> X = cellfun('isempty',regexp(C,'^aaa\d.txt$'));
>> S = S(~X);
>> S.name
ans = aaa0.txt
ans = aaa1.txt
  4 件のコメント
Anil Thota
Anil Thota 2020 年 9 月 30 日
Yes - Same Operating system. What is the wild character for specifying one character?
Thank you,
Anil
Walter Roberson
Walter Roberson 2020 年 9 月 30 日
The Mathworks documentation says that wildcards for single characters is not supported.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by