Code covered by the BSD License  

Highlights from
uipickfiles: uigetfile on steroids

4.93939

4.9 | 35 ratings Rate this file 120 Downloads (last 30 days) File Size: 12.11 KB File ID: #10867
image thumbnail

uipickfiles: uigetfile on steroids

by Douglas Schwarz

 

25 Apr 2006 (Updated 02 Mar 2012)

Many-featured, platform independent file and directory picker.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information
Description

This is a GUI application that allows multiple files or directories to be selected and allows you to manage the list (remove files, reorder, etc.) before returning. It has basic filtering as well as regular expression filtering and navigation of the file system is easy. The output is configurable (cell, struct or char arrays). It is written entirely in M and so is platform independent.

Acknowledgements
This submission has inspired the following:
PIVlab - time-resolved particle image velocimetry (PIV) tool
MATLAB release MATLAB 7.8 (R2009a)
Other requirements Tested on Windows XP, Mac OS X and Ubuntu Linux.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (67)
17 May 2006 Scott Miller

Sweet. This saves me a lot of time; I was going to have to write one of these myself. I like that it is written completely in m script; there is really no point in writting such an interface as a dll if you don't have to, and this makes is easy to customize. It also doesn't seem to to have that "where's my dialog box?" effect of uigetfiles, (NOT uigetfile!), where occasionally, randomly, the dialog box will "open" with the window closed on startup. My only complaint as a windows user is uipickfiles has that funny UNIX smell to the UI (e.g., "..\" instead of an up arrow, files are sorted by case and then alphabetically instead of alphabetically), but hey, you can't have everything, and the script is right there if you want to change something.

15 Jun 2006 Laszlo Totthfalusi

Smashing, cool

10 Jul 2006 Lennaert Klerk

Great!! This saved me so much time and is going to be used a lot by me and my colleagues....

24 Jul 2006 Johann Boleininger

Very useful, many thanks.

17 Feb 2007 Oleksnadr Dzyubak

Just Great!!!
I work on Linux where uigetfile is buggy.
The "uipickfiles" is an excellent workarround.
Many thanks!

16 Mar 2007 Chris K

The interface looks great, but I can't use it because of the following error and others.

??? Subscripted assignment between dissimilar structures.

Error in ==> uipickfiles>add at 353
dir_picks(end + 1) = dir_pick;

??? Error using ==> waitfor
Error while evaluating uicontrol Callback

I am running:
MATLAB Version 7.4.0.287 (R2007a) on Mac OS X

20 Mar 2007 Douglas Schwarz

TMW changed the struct returned by dir in R2007a. I have updated uipickfiles accordingly. (It will still work with older versions of MATLAB.) Thanks for the report.

21 Mar 2007 Chris K

Thank you for updating it! I am thrilled to be able use it!

10 Apr 2007 Patrick Naulleau

Any chance of getting a non-nested function version of this allowing it to work in earlier versions of Matlab?

11 Apr 2007 Douglas Schwarz

Patrick, yes it could be done. Email me and we'll discuss it. -- Doug

18 May 2007 Elakkat D

reallay useful tool

11 Jun 2007 Oleksandr (Alex) Dzyubak

I am working on image processing and for me that is usual practice to have more than 100 images in a set. The native MATLAB utility uigetfile does not support that at the moment.
In fact, uipickfiles DOES. Which is more, it works in Linux and Windows and for R2006b and R2007a. Thanks Douglas!!! Nice product!

Alex

06 Jul 2007 B. Andre Weisntock

I needed an intuitive way for a non-MatLab user to load multiple directories into a MatLab stand-alone application and this product was EXACTLY what was needed. Perfect. Many thanks Doug!

04 Feb 2008 Jeff Meganck

Incredibly useful, very well written program. I have incorporated this program into almost all of my own scripts. I just upgraded to R2007b(7.5.0) and started to get the following problem:

??? Subscripted assignment between dissimilar structures.

Error in ==> uipickfiles>add at 353
dir_picks(end + 1) = dir_pick;

??? Error using ==> waitfor
Error while evaluating uicontrol Callback

The fix was easy. Add 'datenum',[] at the end of line 171 so that it reads:
dir_picks = struct('name',{},'date','','bytes',[],'isdir',[],'datenum',[]);

28 Mar 2008 Joe Spernyak

Great for Queue'ing up lots of files/datasets for overnite processing.

19 Aug 2008 Thomas Ibbotson

This looks like just what I need. However I was getting an error when I first tried to use it. It appears that if you specify a filter which returns no files, there is an error:

??? Error using ==> vertcat
CAT arguments are not consistent in structure field number.

Error in ==> uipickfiles>filtered_dir at 762
d = [ddot1;ddot2;dfiles(index1);ddir(index2)];

Error in ==> uipickfiles at 164
fdir = filtered_dir(full_filter,re_filter);

I fixed this by adding these lines:

762 if ~isempty(dfiles)
763 d = [ddot1;ddot2;dfiles(index1);ddir(index2)];
764 else
765 d = [ddot1;ddot2;ddir(index2)];
766 end

It might not be the best way to do it, but it works for me.

20 Aug 2008 Ben Bratton

Excellent code. Very helpful for myself and colleagues. We work with image processing and this greatly simplifies our lives.

09 Oct 2008 Rene Michels

Great Job,

THX for sharing! It really helps me out!!
Greetings,
Rene

23 Jan 2009 Skip

Very useful. Thank you!

Is it possible to have files added to the list in Ctrl+click order? This would avoid the need to sort files after selecting.

24 Jan 2009 Douglas Schwarz

Skip, you can double-click on a file and it will be added to the list immediately. That may be sufficient for your purposes, but I will look into your suggestion.

24 Jun 2009 J W

Great File! One quick question though - how might I go about removing hidden files from file lists? I notice that when I have hidden files in the same directory as the images I am trying to retrieve, hidden file versions with prefix '._' appear first making file selection very non-intuitive. Any solutions?

25 Jun 2009 J W

Actually, I just found a workaround. At every designation of 'filenames' I follow it with a series of loops testing each filename to see if it is preceded by '._' My supplement to the code is working well if anyone needs to have hidden files removed from file lists.

25 Jun 2009 Douglas Schwarz

J W, what platform are you using and what kinds of files are those? Do the hidden files somehow pair up with non-hidden versions so you have both ._abc.txt and abc.txt? It would be easy to add a feature so that hidden files are not displayed in uipickfiles as long as we can identify them. Tell me more.

11 Sep 2009 Nathan Greco

Very useful, especially when loading in multiple files at one with a regexp filter. Thanks a lot!

14 Sep 2009 Bernd

This would have saved me a lot of programming, well it will even save some time in future....perfekt, classic 5 stars for SUPERUSEFUL

07 Nov 2009 Weimin  
03 Jan 2010 Amjad Elshenawy

Very useful

06 Jan 2010 Andrey Rubshtein

Great! No Guide, does the job, very useful.

05 Feb 2010 W Thielicke

Very nice, I especially like the possibility to sort the filenames manually in the GUI. But when I set 'output' to 'struct' (that is what I need for my application), it doesn't care anymore about manual sorting. Is there a way to fix this problem?

05 Feb 2010 Douglas Schwarz

I just fixed it and uploaded the new version -- it should appear soon. Thanks for the bug report!

08 Feb 2010 W Thielicke

Hey cool, thank you very much!!

16 Mar 2010 gozer

Would like to add my kudos to your work. excellent job....with one question;
I have a need to be able to select files for various directories. But it seems once a select files from one directory, then try to level-up to another it does not refresh the 'pick list'. Am I doing something wrong?

16 Mar 2010 Douglas Schwarz

gozer, I'm not sure what you mean. You should be able to navigate around the file system and add files to the Selected Files list from multiple directories. When you say 'pick list', which one do you mean, the list on the left or the one on the right? The one on the left should show the contents of one directory at a time while the list on the right should show every file you have added to it until you press 'Done'. Please clarify. - Doug

17 Mar 2010 gozer

I should mention one other thing. The directories and files I am accessing are on a network drive...not sure if that makes a difference. (the network drive is specified in the filter property value)

25 Mar 2010 Debanjan Goswami  
16 Apr 2010 Eric

Thanks very much. This is a great tool that I've incorporated into my GUIs when I need to select a large number of files.

28 May 2010 James  
09 Jul 2010 Igor

Very good...

28 Jul 2010 Gergely

That was exactly what I was looking for. Thank You!

04 Aug 2010 Matthew Arthington

This is something TMW should have made a long time ago.

Thank you for sharing it, it works very well.

30 Sep 2010 Asaad Said

Hi Douglas,

I'm having a problem reading many files (>780 files) using uigetfile function. the function works fine if I read less than 780 files. I'm getting the following error message
"File not found. Please verify the correct file name was given"

I looked at this error online, but didn't find any solution online on Mathworks website.
I appreciate if you can help or provide a link for this issue

thanks,
Asaad

30 Sep 2010 Douglas Schwarz

Hi Asaad,

Are you using my function, uipickfiles, or the built-in function uigetfile? If mine, please let me know what arguments you are using.

Doug

28 Oct 2010 sjye  
15 Nov 2010 Zhijiang Wang

Good Job! Good man!

20 Jan 2011 Md. Niazul

I am using this function uipickfiles. But my problem is, GUI of this function does not show the file names in the same order ,as they are in the folder.
In the folder my files look like:

spectrum1_300_315.60039
spectrum1_315.60039_331.20078
..............................
................................
spectrum1_1002.0175_1017.6179...

.................................
but the GUI of this function is showing like this:
spectrum1_1002.0175_1017.6179
...............................
.............................
spectrum1_300_315.60039
spectrum1_315.60039_331.20078

how can i fix the problem ..Could anyone help please.??

20 Jan 2011 Douglas Schwarz

Md. Niazul,

Try replacing the calls to sort in lines 1025-1037 with sort_nat. It might do what you want. It is available from

http://www.mathworks.com/matlabcentral/fileexchange/10959

Doug

10 Mar 2011 Sundeep

That's an excellent tool. All it's really missing is cut/copy/paste functionality. Sounds feasible too.

09 May 2011 Horia

On R2008a,I get the message:
??? Error using ==> setappdata
Invalid object handle

Error in ==> uipickfiles at 382
setappdata(hgui, 'sequencer', 1); %default style

09 May 2011 Douglas Schwarz

Horia, I don't know what function you have because I don't use setappdata in my function at all.

14 May 2011 Horia

It appears in the downloaded file.

14 May 2011 Douglas Schwarz

Horia, try downloading it again because I just downloaded it myself to be sure and setappdata is not in there. The downloaded uipickfiles.m is exactly as it should be.

15 May 2011 Horia

I re-downloaded the file.
When executing the function, I get:

Images=uipickfiles('num',[],'out','cell');
??? Error using ==> setappdata
Invalid object handle

Error in ==> uipickfiles at 382
setappdata(hgui, 'sequencer', 1); %default style

Sorry, but I can't figure why this happens.

15 May 2011 Douglas Schwarz

Horia, you must have another file called uipickfiles.m because that line of code simply does not exist in my function. Run 'which uipickfiles -all' to help sort this out.

14 Jun 2011 Nicolas

Thanks a lot ! Very time saving for me

03 Aug 2011 Lube F

Excellent function. One (stupid) question: I've got long file names and would like the gui window to open maximized so that I can see them fully. Is this possible? Could http://www.mathworks.com/matlabcentral/fileexchange/3812-maximize-window/content/Maximize.m be incorporated if necessary?
Cheers.

09 Aug 2011 Douglas Schwarz

I just uploaded a new version that is resizable and remembers the size and position so you can choose any size you want.

22 Dec 2011 Andrew

Love the program. Only thing I'd like is if you press escape on the keyboard it be the equivalent of clicking the cancel button (it's the only thing uigetfile has up on this one). Thanks.

03 Jan 2012 Douglas Schwarz

Andrew, I'm glad to oblige. I just submitted a version that cancels with a press of the escape key. Thanks for the suggestion.

05 Jan 2012 Bryan

Douglas, great function. I noticed a bug while using on a PC. When I back out all the way to My Computer and open a new drive. I get an error at line 1299 for calling textscan with the first input empty.

05 Jan 2012 Douglas Schwarz

Bryan, that's interesting. Back when I first wrote this function, that was not an error, but at some point TMW changed textscan and I didn't notice. Anyway, I just submitted a fix. Thanks for the report!

29 Feb 2012 Chris

Hey Doug,

I am using this function with Windows 7. When you navigate to your 'My Documents' folder, nothing is displayed because the actual folder name in the directory path is 'Documents'. If I edit the 'My ' out of the path displayed then the directory contents appear. Is there a place in the code where i could search the new directory path for 'My Documents' in order to replace it with 'Documents'? Other directories such as 'My Received Files' do don't exhibit the same error.

29 Feb 2012 Douglas Schwarz

Chris,

I hadn't noticed this before, but I see what you mean. I think I know a way to check if the directory is real or a figment of Window's imagination (like "My Documents" is) so I should be able to drop "My Documents" from the list automatically. Note that "Documents" also appears so if you just select that all is well, but I agree that if "My Documents" doesn't represent a valid choice it shouldn't appear at all. I will work on it and update uipickfiles soon. Thanks for the report.

05 Mar 2012 Douglas Schwarz

Chris, I uploaded a new version that deals with the "My Documents" issue.

04 Apr 2012 Andrew

Thanks for the quick updates. One other request or possible bug fix, in the window it gives options to sort by Date and Size, but date and size aren't displayed for any of the files. Are they supposed to be? I'm running it in Matlab 2012a on a Macintosh. Thx.

04 Apr 2012 Douglas Schwarz

Andrew,

No, they aren't supposed to be displayed. I realize that it's not ideal, but there are two problems with displaying them. (1) There's not enough room. Remember, we have to display both the list of files on the left and the chosen files on the right. To display additional information would simply make the figure too wide. (2) It would be difficult (maybe impossible) to get multiple columns to line up without using a monospaced font. A monospaced font would take up even more room and just exacerbate problem 1.

Those are my reasons, but I will think about your request and if I can come up with a way to do it without sacrificing appearance or functionality I'm not opposed.

Doug

04 Apr 2012 Andrew

Thanks. As long as the sorting works then I'm happy with it. It just wasn't clear that was happening since the values weren't displayed.

16 Apr 2012 Matthew Arthington

Doug and Andrew,

An idea: If displaying information on date and size was very important, perhaps you could use a colormap to shade the background of each file according to its size and/or date, and then only a scale (log scale for size?) would have to be included in the figure window.

Please login to add a comment or rating.
Updates
20 Mar 2007

Updated to work with R2007a.

05 Feb 2010

Fixed bug identified by W Thielicke.

17 Feb 2010

Updated the user interface, appearance, documentation and internal comments.

24 Mar 2010

(Windows only) Now works correctly with UNC-named resources (e.g., \\machine\share).

09 Aug 2010

Minor interface changes -- backspace will go up one directory, control-A (command-A on the Mac) will select all as before, but won't cause menu bar to appear.

17 Oct 2010

Recent Folders list (right-click path box) is now sorted in chronological order and is persistent between calls (via a preferences setting). Also, ctrl-F will select all files (leaving folders unselected).

07 Mar 2011

Added ability to recall previous selections. Fixed a few minor bugs.

08 Mar 2011

Fixed bug in yesterday's version in recalling folders.

21 Mar 2011

Added ability to sort file list by name, date or size.

09 Aug 2011

GUI is now resizable and remembers the size and position last used.

03 Jan 2012

Added use of escape key as equivalent to Cancel button.

05 Jan 2012

Fixed bug identified by Bryan.

02 Mar 2012

Addressed problem mentioned by Chris. Now, on Windows, an attempt to open "My Documents" will be silently converted to an open of "Documents" instead if "My Documents" doesn't really exist.

Tag Activity for this File
Tag Applied By Date/Time
gui tools Douglas Schwarz 22 Oct 2008 08:23:18
example Douglas Schwarz 22 Oct 2008 08:23:18
uigetfile uigetfiles files directory Douglas Schwarz 22 Oct 2008 08:23:18
multiple file selection Andrey Rubshtein 06 Jan 2010 11:35:32
example Tim 17 Feb 2010 11:00:13
potw Shari Freedman 18 Feb 2010 12:03:59
pick of the week Jiro Doke 11 Feb 2011 20:04:43
example anoop 26 Apr 2011 17:20:14
example Gopinath 22 Jul 2011 07:28:00
example Bram Roozendaal 07 Feb 2012 18:16:10
example Ergon 22 Feb 2012 11:57:17

Contact us at files@mathworks.com