Function Repository Resource:

FileTreePicker

Source Notebook

Create a file tree with expandable directories to select multiple files

Contributed by: Sjoerd Smit

ResourceFunction["FileTreePicker"][Dynamic[files],dir]

creates a file tree with checkboxes to select files in directory dir and all its subdirectories.

ResourceFunction["FileTreePicker"][Dynamic[files],dir,depth]

only shows files at depth specification depth as used by FileSystemMap.

ResourceFunction["FileTreePicker"][Dynamic[files]]

uses a SystemDialogInput to pick the root directory.

Details and Options

The default depth specification is Infinity.
Empty directories will be omitted in the interface.
ResourceFunction["FileTreePicker"] takes the following options from FileSystemMap:
FileNameFormsAllinclude files with names of the specified forms
MaxItemsInfinitymaximum items to include from a directory

Examples

Basic Examples (2) 

See and select files up to three levels down from the installation directory:

In[1]:=
ResourceFunction["FileTreePicker"][
 Dynamic[files], $InstallationDirectory, 3]
Out[1]=

See the selected files:

In[2]:=
files
Out[2]=

Options (2) 

FileNameForms (1) 

Only show.wl and.nb files:

In[3]:=
ResourceFunction["FileTreePicker"][
 Dynamic[files], $InstallationDirectory, FileNameForms -> {"*.wl", "*.nb"}]
Out[3]=

MaxItems (1) 

Limit the number of files shown per directory:

In[4]:=
ResourceFunction["FileTreePicker"][
 Dynamic[files], $InstallationDirectory, MaxItems -> 5]
Out[4]=

Possible Issues (1) 

Directories with many items to display will take a while to format in the front end so a placeholder will be shown while it's opening:

In[5]:=
ResourceFunction["FileTreePicker"][
 Dynamic[files], $InstallationDirectory]

Publisher

Sjoerd Smit

Version History

  • 1.0.0 – 12 September 2022

License Information