Files.DeleteFolder
------------------

Deletes a file or folder directly without moving to trash.

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

MBS( "Files.DeleteFolder"; Path ) 

**MBS**( **"Files.DeleteFolder";** /\* Deletes a file or folder directly without moving to trash. \*/  
**$Path**) /\* The native folder path to the item to be deleted.e.g. "/Users/John/Desktop/test" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Path | The native folder path to the item to be deleted. | "/Users/John/Desktop/test" |

### Result

Returns OK or error message.

### Description

Deletes a file or folder directly without moving to trash.  
Use [Files.MoveToTrash](FilesMoveToTrash.md) to move files to trash which is often better as it allows users to undo the operation. Also [Files.MoveToTrash](FilesMoveToTrash.md) usually works on files in use.  
  
It is possible that the OS decides to not delete the file and fail (e.g. due to permission errors).  
Folders are deleted recursively.  
  
On Linux in v13.0 or newer, we try to delete the folder. If that fails, because the file is not empty, we will recursively delete the content. Once that is done, we try again. If something failed to delete inside the folder, the function will report the error about directory not being empty.  
  
This function requires a native path. Use [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md) to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use [FileDialog](component_FileDialog.md) functions.  
For Server be aware that server has limited permissions and may not be able to access all files on a computer.  
### Examples

Delete a folder on desktop on Mac:

 $r = MBS ("[Files.Delete](FilesDelete.md)"; "/Users/cs/Desktop/testing")  
Delete a folder on desktop on Windows:

 $r = MBS ("[Files.Delete](FilesDelete.md)"; "C:\\Users\\Christian\\Desktop\\testing")  
### See also

- [Files.CreateDirectory](FilesCreateDirectory.md)
- [Files.Delete](FilesDelete.md)
- [Files.DeleteLater](FilesDeleteLater.md)
- [Files.MoveToTrash](FilesMoveToTrash.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)

### Release notes

- **Version 13.0**
    - Changed [Files.DeleteFolder](https://www.mbsplugins.eu/FilesDeleteFolder.shtml) for Linux to do recursive deletion.

### Example Databases

- [Mac and iOS/PDFKit/PDFKit Print Documents](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/PDFKit/PDFKit%20Print%20Documents.shtml#4ScriptAnchor_)

### Blog Entries

- [MBS Plugin Advent calendar: 12 - Files](https://www.mbsplugins.de/archive/2023-12-12/MBS_Plugin_Advent_calendar_12_/monkeybreadsoftware_blog_filemaker)
- [Neues MBS Plugin 13.0 für Claris FileMaker](https://www.mbsplugins.de/archive/2023-01-17/Neues_MBS_Plugin_130_für_Clar/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin 13.0 for Claris FileMaker](https://www.mbsplugins.de/archive/2023-01-17/MBS_Plugin_130_for_Claris_File/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 13.0pr6](https://www.mbsplugins.de/archive/2023-01-09/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Convert Office Files in FileMaker](https://www.mbsplugins.de/archive/2022-07-04/Convert_Office_Files_in_FileMa/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 4.2pr8](https://www.mbsplugins.de/archive/2014-05-27/MBS_Filemaker_Plugin_version_4/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 4/2020, Seite 35](https://filemaker-magazin.de/neuigkeit/4103-Appetithappen-FMM_202004)
- [Ausgabe 2/2017, Seite 41](https://filemaker-magazin.de/neuigkeit/3930-Appetithappen-FMM_201702)

This function checks for a license.

Created 18th August 2014 , last changed 13th January 2023

  
[Files.Delete](FilesDelete.md) - [Files.DeleteLater](FilesDeleteLater.md)

[HTML Version](FilesDeleteFolder.shtml)