Files.List
----------

Queries list of file names in folder.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Files](component_Files.md) | [2.8](newinversion28.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Files.List"; Path { ; Filter; ExtensionFilter } ) 

**MBS**( **"Files.List";** /\* Queries list of file names in folder. \*/  
**$Path**; /\* Native path to the directory.e.g. "C:\\Test" \*/   
**$Filter**; /\* Optional; Optional, limits what is returned.   
Default is 0 to report all files.   
  
Pass a combination of the following values:  
1 for showing only files,   
2 for showing only directories and   
4 for showing only visible items.  
8 if the path includes the file name specification with wildcards; a.k.a glob.  
128 to use the extension filter text and do a substring match on the file name.  
  
e.g. pass 4+1 for visible files or 2+4 for visible directories.e.g. 5 \*/   
**$ExtensionFilter**) /\* Optional; Optional, a filter for getting only files with matching file extension.  
Since version 16.1 this can be a list.e.g. ".txt" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Path | Native path to the directory. | "C:\\Test" |  |
| Filter | Optional, limits what is returned.    Default is 0 to report all files.       Pass a combination of the following values:   1 for showing only files,    2 for showing only directories and    4 for showing only visible items.   8 if the path includes the file name specification with wildcards; a.k.a glob.   128 to use the extension filter text and do a substring match on the file name.      e.g. pass 4+1 for visible files or 2+4 for visible directories. | 5 | Optional |
| ExtensionFilter | Optional, a filter for getting only files with matching file extension.   Since version 16.1 this can be a list. | ".txt" | Optional |

### Result

Returns list of files separated by return.

### Description

Queries list of file names in folder.  
The list of names is separated by new line character.  
This function needs a native path. Please use [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md) function in order to convert a FileMaker style path to a native path.  
With filter parameter being 8 on Windows, you can pass a path with wildcards directly and ExtensionFilter parameter is ignored. This is not supported on macOS.  
  
See also [Files.ListRecursive](FilesListRecursive.md). You can filter result with [List.MatchesPostfix](ListMatchesPostfix.md) to get list with one file extension only.  
  
Our plugin does not sort and return the files in the order the OS returned them. If you need sorting, please check [List.Sort](ListSort.md) function. Also use [List.RemovePrefix](ListRemovePrefix.md) or [List.RemovePostfix](ListRemovePostfix.md) to filter list further.  
  
On macOS, if you can't read a directory, please also check privacy system settings for whether FileMaker has permissions to look into desktop, documents or downloads folder or remote volumes.  
### Examples

Queries files in Users folder on Mac:

 Set Variable \[ $FileList ; Value: MBS ("Files.List"; "/Users") \]  
Queries visible files in windows folder:

 Set Variable \[ $FileList ; Value: MBS ("Files.List"; "c:\\\\Windows\\\\"; 5) \]  
Queries DLL files in windows folder:

 Set Variable \[ $FileList ; Value: MBS ("Files.List"; "c:\\\\Windows\\\\"; 0; ".dll") \]  
Queries Applications with name starting with e in windows folder:

 Set Variable \[ $FileList ; Value: MBS ("Files.List"; "c:\\\\Windows\\\\e\*.exe"; 8) \]  
Find FileMaker databases in a folder:

 Set Variable \[ $FileList ; Value: MBS ("Files.List"; "c:\\\\Users\\\\Christian\\\\Desktop"; 0; ".fmp12”)\]  
Query all file names and sizes for files on desktop:

 While(   
\[   
 names = "";   
 // query list of visible files on desktop  
 folder = MBS ("[Folders.UserDesktop](FoldersUserDesktop.md)");  
 list = MBS ( "Files.List"; folder; 1+4 );   
 count = ValueCount(list);   
 index = 1  
\] ;   
 index ≤ count ;   
\[   
 filename = GetValue(list; index);   
 filepath = MBS ("[Path.AddPathComponent](PathAddPathComponent.md)"; folder; filename);  
 // query size for each file  
 size = MBS ( "[Files.FileSize](FilesFileSize.md)"; filepath);   
 names = names &amp; filename &amp; " -&gt; " &amp; size &amp; ¶;   
 index = index + 1   
\] ;   
// return all the names  
names )  
<small>  
Example result:   
test.zip -&gt; 834  
test.rtf -&gt; 400</small>Import all files in a folder:

 # list files in a folder   
Set Variable \[ $r ; Value: MBS ("Files.List"; $FolderPath ) \]   
  
\# loop over the files   
Set Variable \[ $count ; Value: ValueCount ( $r ) \]   
Set Variable \[ $index ; Value: 0 \]   
If \[ $count &gt;0 \]   
 Loop  
 # build path  
 Set Variable \[$fileName ; GetValue ( $r ; $index +1 )\]  
 Set Variable \[$filePath ; Value: MBS ( "[Path.AddPathComponent](PathAddPathComponent.md)"; $FolderPath ; $fileName )\]  
 Set Variable \[$fileData ; Value: MBS ("[Container.ReadFile](ContainerReadFile.md)"; $filePath )\]  
  
 # create record for new file  
 New Record/Request  
 Set Field \[MyData::Container ; $fileData \]  
 Set Field \[MyData::Name ; $fileName \]   
 Commit Records/Requests \[ With dialog: Off \]   
  
 Set Variable \[ $index ; Value: $index + 1 \]   
 Exit Loop If \[ $index = $count \]   
 End Loop  
End If  
List only text and RTF files on desktop:

 MBS ( "Files.List"; MBS ("[Folders.UserDesktop](FoldersUserDesktop.md)"); 4; ".txt¶.rtf" )  
<small>  
Example result:   
test.txt  
test.rtf</small>### See also

- [Files.ListOpenFiles](FilesListOpenFiles.md)
- [Files.ListRecursive](FilesListRecursive.md)
- [Files.ListVolumes](FilesListVolumes.md)
- [Folders.UserDesktop](FoldersUserDesktop.md)
- [List.Remove](ListRemove.md)
- [List.Sort](ListSort.md)
- [Path.AddPathComponent](PathAddPathComponent.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)
- [SyntaxColoring.AddContextMenuCommand](SyntaxColoringAddContextMenuCommand.md)
- [Text.ReadTextFile](TextReadTextFile.md)

### Release notes

- **Version 16.2**
    - Renamed [Files.OpenFiles](https://www.mbsplugins.eu/FilesListOpenFiles.shtml) to [Files.ListOpenFiles](https://www.mbsplugins.eu/FilesListOpenFiles.shtml).
- **Version 16.1**
    - Changed [Files.List](https://www.mbsplugins.eu/FilesList.shtml), [Files.ListAsJSON](https://www.mbsplugins.eu/FilesListAsJSON.shtml) and [Files.ListRecursive](https://www.mbsplugins.eu/FilesListRecursive.shtml) to accept a list for ExtensionFilter parameter.
- **Version 15.2**
    - Added ExtensionFilter parameter to [Files.ListRecursive](https://www.mbsplugins.eu/FilesListRecursive.shtml) function.
    - Added flag 128 for matching substring with the ExtensionFilter parameter for the [Files.List](https://www.mbsplugins.eu/FilesList.shtml), [Files.ListAsJSON](https://www.mbsplugins.eu/FilesListAsJSON.shtml) and [Files.ListRecursive](https://www.mbsplugins.eu/FilesListRecursive.shtml) functions.
- **Version 13.5**
    - Added IsApplication and IsPackage for [Files.ListAsJSON](https://www.mbsplugins.eu/FilesListAsJSON.shtml) function.
    - Fixed [Files.ListAsJSON](https://www.mbsplugins.eu/FilesListAsJSON.shtml) function to not filter invisible files on macOS without asked to do that.
- **Version 12.2**
    - Fixed [Files.List](https://www.mbsplugins.eu/FilesList.shtml) to better check directory status on macOS using alternative code path.
- **Version 11.5**
    - Fixed [Files.ListAsJSON](https://www.mbsplugins.eu/FilesListAsJSON.shtml) to query date and size of a symlink instead of the target.
- **Version 10.5**
    - Added [Files.ListAsJSON](https://www.mbsplugins.eu/FilesListAsJSON.shtml) function to list files and return it as JSON.
- **Version 8.4**
    - Changed [Files.ListRecursive](http://www.mbsplugins.eu/FilesListRecursive.shtml) to use either / or \\ for path delimiter on Windows.
- **Version 7.3**
    - Added new flag for [Files.ListRecursive](http://www.mbsplugins.eu/FilesListRecursive.shtml) to ignore invisible folders and better check for hidden elements.

### Example Databases

- [CURL/WebServices/WeatherBit.io test](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/WebServices/WeatherBit.io%20test.shtml#4ScriptAnchor_)
- [Files/File Listing With Icons](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Files/File%20Listing%20With%20Icons.shtml#1ScriptAnchor_)
- [Files/File listing](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Files/File%20listing.shtml#1ScriptAnchor_)
- [Files/FileOperation](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Files/FileOperation.shtml#7ScriptAnchor_)
- [Mac and iOS/PDFKit/PDFKit Print Documents](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/PDFKit/PDFKit%20Print%20Documents.shtml#4ScriptAnchor_)
- [Mac and iOS/PDFKit/Pictures to PDF](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/PDFKit/Pictures%20to%20PDF.shtml#3ScriptAnchor_)
- [Mac only/Icon and QuickLook/QuickLook Preview Panel](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20only/Icon%20and%20QuickLook/QuickLook%20Preview%20Panel.shtml#3ScriptAnchor_)
- [Python](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Python.shtml#1ScriptAnchor_)
- [SQL in FileMaker/ImageGallery](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20in%20FileMaker/ImageGallery.shtml#1ScriptAnchor_)
- [Win Only/Snippets for Windows](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Win%20Only/Snippets%20for%20Windows.shtml#11ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 16.1pr5](https://www.mbsplugins.de/archive/2026-03-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Using Python in FileMaker](https://www.mbsplugins.de/archive/2024-06-24/Using_Python_in_FileMaker/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin Advent calendar: 12 - Files](https://www.mbsplugins.de/archive/2023-12-12/MBS_Plugin_Advent_calendar_12_/monkeybreadsoftware_blog_filemaker)
- [Convert Office Files in FileMaker](https://www.mbsplugins.de/archive/2022-07-04/Convert_Office_Files_in_FileMa/monkeybreadsoftware_blog_filemaker)
- [Recursive Folder Copy Script](https://www.mbsplugins.de/archive/2021-11-12/Recursive_Folder_Copy_Script/monkeybreadsoftware_blog_filemaker)
- [Combined Components with MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2021-03-29/Combined_Components_with_MBS_F/monkeybreadsoftware_blog_filemaker)
- [New in the MBS FileMaker Plugin 10.0](https://www.mbsplugins.de/archive/2020-01-23/New_in_the_MBS_FileMaker_Plugi/monkeybreadsoftware_blog_filemaker)
- [Parsing VCard file](https://www.mbsplugins.de/archive/2017-11-13/Parsing_VCard_file/monkeybreadsoftware_blog_filemaker)
- [Comparing Base Elements Plugin to MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2017-10-24/Comparing_Base_Elements_Plugin/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 2.8 for OS X/Windows - More than 1100 Functions In One Plugin](https://www.mbsplugins.de/archive/2012-08-07/MBS_FileMaker_Plugin_28_for_OS/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 4/2020, Seite 34](https://filemaker-magazin.de/neuigkeit/4103-Appetithappen-FMM_202004)
- [Ausgabe 1/2017, Seite 10](https://filemaker-magazin.de/neuigkeit/3923-Appetithappen-FMM_201701)

This function checks for a license.

Created 18th August 2014 , last changed 24th February 2026

  
[Files.LaunchFile](FilesLaunchFile.md) - [Files.ListAsJSON](FilesListAsJSON.md)

[HTML Version](FilesList.shtml)