Showing certain files in a dialog window

Hi,
I want to get a dialog window (uigetfile/uigetdir style) which shows files already filtered by a certain criteria (in this case, modification date being between 2 specified dates). I did discard undesired files by the use of datetime and isbetween:
foldinfo=dir();
foldinfo([foldinfo.isdir]) = [];
tempfile=struct2cell(foldinfo);
[y,m,d]=ymd(datetime(tempfile(2,:)));
c=datetime(y,m,d);
indexs=isbetween(c,Since,To);
foldinfo(indexs)=[];
where "Since" and "To" are datetime format. With this I end up only with the files of interest that I want to be displayed on the dialog box. However, I don't know how to allow the user to select files ONLY among the filtered files.
Does anybody know a way to do this?

 Accepted Answer

Read about listdlg ....
Let str be the files which you have selected and you want user to select from these. This code should help you to do what you want:
[s,v] = listdlg('PromptString','Select a file:',...
'SelectionMode','single',...
'ListString',str) ;

More Answers (1)

Thanks for your response KSSV. It was useful to get the indices of the selected files in their directory and their name:
indexs=isbetween(c,VDesde,VFins);
foldinfo(~indexs)=[];
[s,v] = listdlg('PromptString','Select files:','SelectionMode','multiple',...
'ListString',{foldinfo.name})
names=tempfile(1,s); %this obtains the names
indexsones=find(indexs==1); %this obtains the indices in the directory
files=indexsones(s);

Categories

Community Treasure Hunt

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

Start Hunting!