dir search multiple files

Hello,
I am using the dir command to search a folder for specific file types. I am looking for both *.jpg and *.png files. How do I structure my statement so that I can search for both file types?

Answers (1)

Fangjun Jiang
Fangjun Jiang on 19 Sep 2011

7 votes

Files=[dir('*.jpg');dir('*.png')]

3 Comments

I think that might be the only option on MS Windows.
On OS-X or Linux there might be an additional more obscure method,
dir('*.{jpg,png}')
This should NOT be expected to work on MS Windows.
I know this is an old link, but it totally saved me. Thanks!
helped me too!!

Sign in to comment.

Categories

Tags

Asked:

on 19 Sep 2011

Commented:

on 9 Mar 2018

Community Treasure Hunt

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

Start Hunting!