How to list files with multiple extensions?
38 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Suppose I want mp3 or avi files from a folder, on Unix I could do
ls *.{mp3|avi}
Is there a clean one-liner way to do this in matlab? Presently, I can do it in two lines by doing the following:
f = dir(folder)
f(~cellfun(@isempty,regexpi({f.name},'.*(mp3|avi)'))).name
However, I find this rather ugly compared to the simplicity of the first expression.
Thanks, Kevin
1 comentario
Respuestas (3)
Doug Hull
el 24 de Oct. de 2012
Can you run the command twice with two filters? The results would be two structures of the same format that could then be appended together.
2 comentarios
Sean de Wolski
el 24 de Oct. de 2012
@Kevin, a for-loop over a cell array containing the extentions would allow it to scale, though concatenating structures is ugly.
Sean de Wolski
el 24 de Oct. de 2012
You could just farm that command out to Unix if you are on a unix system...
ANKUR WADHWA
el 6 de Nov. de 2019
Editada: Cris LaPierre
el 9 de En. de 2024
Though the thread is very old still for users who are looking for an easy way a very simple existing solution on Matlbcentral
0 comentarios
Ver también
Categorías
Más información sobre Characters and Strings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!