How do I grab individual files from a directory path?
6 ビュー (過去 30 日間)
古いコメントを表示
I am creating a GUI and I want the user to be able to select a file containing multiple .xml files, and then I need to be able to parse and work with the files within that directory separately. Right now, I am using uigetdir to get the file path but as that just returns a string, I do not know how to use that file path to grab the individual files. Any help will be appreciated, thanks!
0 件のコメント
採用された回答
Stephen23
2015 年 5 月 4 日
編集済み: Stephen23
2015 年 5 月 4 日
You can use dir to get a list of all of the files in a directory. It also allows you to specify the a string to match particular files, you could use '*.xml' to select only files with that extension: see the documentation for more info and examples. Also note that you should use fullfile to generate the full filepath string:
pth = uigetdir(...);
fnm = fullfile(pth, '*.xml');
S = dir(fnm);
Where S is a structure containing lots of useful info. You can get a cell array of the filenames like this:
C = {S.name};
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!