Skip to main content

TrFile_CreateFolder (function reference)

By June 1, 2024June 4th, 2024Online Help, Troi File Plug-in
Troi File Plug-in > Functions reference > TrFile_CreateFolder
Troi File Plug-in for FileMaker Pro

TrFile_CreateFolder

Creates a new (empty) folder (subdirectory).

SyntaxFunction badge

TrFile_CreateFolder ( switches ; folderPath )

Parameters

switches reserved for future use, leave empty or set to "-Unused"
folderPath the path to the folder to create

Returned Result

Data type returned

Error code

Result

The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:

0 no error The folder was created
$$-48 dupFNErr Destination folder already exists
$$-1 genericErr The folder could not be created
$$-50 paramErr Parameter error

Other errors may be returned.

Originated in

Troi File Plug-in 1.1

Compatibility

FileMaker Pro 17 to FileMaker Pro 21 (2024)

Considerations

You can use FileMaker styled paths, like “filemac:/MacHD/folder/subfolder”.
Starting with Troi File Plug-in 12.0 you can omit filemac: or filewin: too! Any path starting with a slash will be parsed as a FileMaker style path (of the platform FileMaker is running).
See also the functions: TrFile_SelectFolderDialog to get a folderPath for a folder, and TrFile_CreateFile to create a new empty file.

v6.0 improved the TrFile_CreateFolder function: you can now specify a path and the plug-in will create the folder, including all subfolders in the path that do not exist.

Example

We assume that a global number field gErrorCode is defined. Create the following script:

Set Field [ gErrorCode ; TrFile_CreateFolder ( "-Unused" ; "C:\Data\NewFolder" ) ]

This script will create the folder “NewFolder” inside the Data folder on the C disk.
On macOS this will be:

Set Field [ gErrorCode ; TrFile_CreateFolder ( "-Unused" ;  "MyDisk:Data:NewFolder" ) ]

Example 2

We assume that in your FileMaker file the following fields are defined:

  gErrorCode		Global, number
  gFolderPath		Global, text

gFolderPath should contain the path to the folder to be created and should not exist, for example “D:\Logs\Data” (Windows) or “Mac HD:Logs:Data” (macOS). In a script add the following scriptstep:

Set Field [ gErrorCode ; TrFile_CreateFolder ( "-Unused" ; gFolderPath ) ]

This will create the folder specified in the gFolderPath.

Used in example file

CreateFolder.fmp12

Related functionsFunction badge

TrFile_CreateFile
TrFile_DeleteFolder
TrFile_SelectFileDialog
TrFile_SelectFolderDialog

Related script stepScript step badge

Create Folder

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 17 to 2024 –> TrFile_CreateFolder (filep4212) 2024-0604 19:26:38