wildcard in dir command - single char

17 visualizaciones (últimos 30 días)
barak ostraich
barak ostraich el 23 de Jul. de 2019
Comentada: Walter Roberson el 30 de Sept. de 2020
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

Respuestas (1)

Stephen23
Stephen23 el 23 de Jul. de 2019
Editada: Stephen23 el 23 de Jul. de 2019
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 comentarios
Anil Thota
Anil Thota el 30 de Sept. de 2020
Yes - Same Operating system. What is the wild character for specifying one character?
Thank you,
Anil
Walter Roberson
Walter Roberson el 30 de Sept. de 2020
The Mathworks documentation says that wildcards for single characters is not supported.

Iniciar sesión para comentar.

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by