List of Files on a folder
8 views (last 30 days)
Show older comments
Hi, I have been trying to make this... A dialog box where my input is a directory, once I entry a directory it shows a list of a files contained in the directory... I have tried in so many ways and nothing works :( thanks for advance
0 Comments
Answers (1)
Sebastian Castro
on 14 May 2015
To make a dialog box, you can use the uigetdlg function:
dirName = inputdlg('Enter value here:')
Then, whatever is returned by the dialog, you can use with the dir function. Notice I had to index into the results because of the way they are formatted:
dirInfo = dir(dirName{1})
That dirInfo variable will be a structure array that will, among other things, have a "name" field associated with it. So I can say:
dirInfo(6).name
ans =
downloads
Also, there is a function called uigetdir which lets you pick a folder using your operating system's file browser (e.g. Windows Explorer). Try this out, as maybe it is closer to what you need?
dirName = uigetdir
- Sebastian
0 Comments
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!