-2

How can i search for files of a particular type say .jpg files in a particular folder using uigetfile()?

It will be very helpful if files in the sub-folders can also be searched for?

IKavanagh
  • 6,089
  • 11
  • 42
  • 47
Saurabh
  • 3
  • 3
  • What you mean by "search"? – NKN Aug 12 '14 at 09:12
  • For example I select a folder which contains several sub-folders, so I want the paths of say all the .jpg files in each sub-folder and the folder itself. – Saurabh Aug 12 '14 at 09:20

2 Answers2

1

You could first fetch all files from the directory (and subdirectories). There's an excellent answer for this problem. Look here: How to get all files under a specific directory in MATLAB?. To select the folder you can use the matlab command: uigetdir

Subsequently just loop over the list and collect all names that end with ".jpg".

Community
  • 1
  • 1
zinjaai
  • 2,345
  • 1
  • 17
  • 29
0

Something like that should do:

[FileName,PathName] = uigetfile('*.jpg','Select the image file');

Check the documentation for more details.

am304
  • 13,758
  • 2
  • 22
  • 40
  • Actually, I want to browse a directory and inside this I want the paths of all the .jpg files. – Saurabh Aug 12 '14 at 09:22
  • Then your question is badly formulated. You don't want to use `uigetfile` at all, but rather `dir`. Again check the documentation, it's fairly obvious what you need to do. – am304 Aug 12 '14 at 09:37