Files.CreateDirectory
---------------------

Creates a directory.

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

MBS( "Files.CreateDirectory"; Path ) 

**MBS**( **"Files.CreateDirectory";** /\* Creates a directory. \*/  
**$Path**) /\* Native path to the new directory to be created.e.g. "C:\\Test" \*/ 

(old name: Files.CreateFolder)

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Path | Native path to the new directory to be created. | "C:\\Test" |

### Result

Returns "OK" or error message.

### Description

Creates a directory.  
Returns "OK" if the directory already exists.  
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.  
For MacOS &amp; iOS creates folders recursively as needed.  
  
In the Mac world we call it a folder, in the Windows world a directory. This function works cross platform and got the name with Directory years ago.  
  
You can use [Files.DeleteFolder](FilesDeleteFolder.md) to delete a folder with its content.  
Changed for plugin version 10.5 to do recursive folder creation on Windows, too.  
### Examples

Create folder on Desktop:

 Set Variable \[$folder ; Value:MBS ( "[Folders.UserDesktop](FoldersUserDesktop.md)" )\]  
If \[IsEmpty(Container Export::Name )\]  
 Set Field \[Container Export::Name ; "Record " &amp; Get(RecordID)\]  
End If  
Set Variable \[$path ; Value:MBS ( "[Path.AddPathComponent](PathAddPathComponent.md)"; $folder ; Container Export::Name )\]  
Set Variable \[$r ; Value:MBS ("Files.CreateDirectory"; $path )\]  
Creates directory and shows error:

 Set Variable \[$r ; Value:MBS ("Files.CreateDirectory"; $path )\]  
If \[MBS ("IsError")\]  
 Show Custom Dialog \["Failed to create directory"; MBS ("[Text.RemovePrefix](TextRemovePrefix.md)"; $r ; "\[MBS \] ")\]  
 Exit Script \[\]  
End If  
Create a folder:

 MBS ( "Files.CreateDirectory"; "/Users/cs/Documents/FolderName" )  
Create recursive folder structure on desktop:

 MBS ( "Files.CreateDirectory"; "C:\\\\Users\\\\Christian\\\\Desktop\\\\test1\\\\test2\\\\test3\\\\" )  
// needs MBS Plugin 10.5 or newer  
### See also

- [Files.Delete](FilesDelete.md)
- [Files.DeleteFolder](FilesDeleteFolder.md)
- [Folders.UserDesktop](FoldersUserDesktop.md)
- [Folders.UserDocuments](FoldersUserDocuments.md)
- [Folders.UserDownloads](FoldersUserDownloads.md)
- [IsError](IsError.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)
- [Text.RemovePrefix](TextRemovePrefix.md)
- [Text.WriteTextFile](TextWriteTextFile.md)
- [WIA.ImageDialog](WIAImageDialog.md)

### Release notes

- **Version 10.5**
    - Changed [Files.CreateDirectory](https://www.mbsplugins.eu/FilesCreateDirectory.shtml) to create folders recursively on Windows, too.

### Example Databases

- [CURL/Email/Email Parser and Preview](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/Email%20Parser%20and%20Preview.shtml#2ScriptAnchor_)
- [CURL/Email/IMAP Email](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/IMAP%20Email.shtml#6ScriptAnchor_)
- [DynaPDF/RenderJob](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/RenderJob.shtml#1ScriptAnchor_)
- [DynaPDF/Scan with WIA to PDF](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Scan%20with%20WIA%20to%20PDF.shtml#7ScriptAnchor_)
- [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_)
- [Utility functions/Split DDR](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Utility%20functions/Split%20DDR.shtml#1ScriptAnchor_)
- [Win Only/Scanning/WIA Scan](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Win%20Only/Scanning/WIA%20Scan.shtml#7ScriptAnchor_)

### Blog Entries

- [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)
- [MBS FileMaker Plugin, version 10.5pr6](https://www.mbsplugins.de/archive/2020-10-26/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Storing files for download on FileMaker Server with download URLs](https://www.mbsplugins.de/archive/2018-09-20/Storing_files_for_download_on_/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)

### FileMaker Magazin

- [Ausgabe 6/2022, Seite 14](https://filemaker-magazin.de/neuigkeit/4206-Appetithappen-FMM_202206)
- [Ausgabe 6/2018, Seite 30 bis 31](https://filemaker-magazin.de/neuigkeit/4025-Appetithappen-FMM_201806)
- [Ausgabe 2/2017, Seite 41](https://filemaker-magazin.de/neuigkeit/3930-Appetithappen-FMM_201702)
- [Ausgabe 2/2017, Seite 38 bis 39](https://filemaker-magazin.de/neuigkeit/3930-Appetithappen-FMM_201702)
- [Ausgabe 1/2017, Seite 10](https://filemaker-magazin.de/neuigkeit/3923-Appetithappen-FMM_201701)

Created 18th August 2014 , last changed 23th October 2020

  
[Files.CreateBookmark](FilesCreateBookmark.md) - [Files.CreateHardLink](FilesCreateHardLink.md)

[HTML Version](FilesCreateDirectory.shtml)