Reputation: 7742
I'm using uigetfile with a custom set of FilterSpecs. Here is the sentence:
[FileName,PathName,FilterIndex] = uigetfile({'*.wav';'*.mp3'},'Open Audio File');
As you can see my FilterSpec is {'*.wav';'*.mp3'}
and this works perfectly fine. My problem is simple, is just that matlab is always appending AllFiles(*.*)
to my FilterSpecs. I have searched in Matlab docs and it literally states:
"uigetfile appends All Files(.) to the file types when FilterSpec is a string.", but the problem is that I don't see another way of specifying a custom FilterSpec without using strings.Sorry if this results in a dumb question.
Thanks in advance
Upvotes: 0
Views: 1199
Reputation: 1
If you back up a few lines from the previous poster's answer, you'll see a comment:
We want to add 'All Files' in all cases unless we have a cell array with descriptors.
This comment is on line 245 of uigetputfile_helper for me. Simply describe your file types at the time you call uigetfile
, and you won't see All Files (*.*)
Example:
[fname,pname] = uigetfile({'*.m','MATLAB Code (*.m)';'*.mat','MATLAB Data (*.mat)'});
Upvotes: 0
Reputation: 1
There's no way to (easily) remove the 'AllFiles' from uigetfile()
since it's always added by MATLAB.
If you really want to do it, you have to copy the uigetputfile_helper()
code (to
MYuigetputfile_helper()
for example) and change it. And then you call it from your MYuigetfile()
- same idea here.
The change would be around lines 311 and 319 in my version from uigetputfile_helper()
, i.e.
% Now add 'All Files' appropriately.
if (addAllFiles)
% If a string, create a cell array and append '*.*'.
if (~iscell(returned_filter))
returned_filter = {returned_filter; '*.*'};
% If it is a cell array without descriptors, add '*.*'.
elseif (size(returned_filter, 2) == 1)
returned_filter{end+1} = '*.*';
end
end
Hope that helps... have fun!
Upvotes: 0