Create an alias file (or shortcut) from the source file or source folder.
TrFile_CreateAlias( switches ; sourcePath ; destAliasSpec )
|switches||modifies the behavior of the function|
|sourcePath||the path to the file, folder or disk of which an alias (shortcut) must be created|
|destAliasSpec||the path to the alias file|
Data type returned
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 alias was created|
|$$-43||fnfErr||Source file/folder not found|
|$$-48||dupFNErr||Destination alias already exists|
Other errors may be returned.
Troi File Plug-in 8.5
FileMaker Pro 16 to 19
To make it easier to find a file, folder, app, or disk, you can create an alias for it in an easy-to-find location. When you open an alias in the Finder or Windows explorer, the original item opens.
On Windows this is called a shortcut, and always has the extension .lnk.
Set Field [ $ErrorCode ; TrFile_CreateAlias ( "-Unused" ; "D:\myReport2016.pdf"; "C:\workDir\currentReport.pdf" ) ]
This will create the shortcut currentReport.pdf.lnk in the folder workDir, which links to the original myReport2016.pdf file.
We assume that in your FileMaker file the following fields are defined and filled with the paths to the source file (or folder) and destination alias:
this::sourcePath may contain something like "MacHD:Users:kip:Report folder" this::destAlias_Path may contain something like "MacHD:Users:kip:Desktop:AliasToFolder"
This example will first set the variables from the paths stored in the two fields, and then create the alias. In a script add the following steps:
# Initialize: copy the fields into variables first: Set Variable [ $SourcePath ; this::sourcePath ] Set Variable [ $DestAlias ; this::destAlias_Path ] # Now create the alias: Set Variable [ $ErrorCode ; TrFile_CreateAlias ( "-Unused" ; $SourcePath ; $DestAlias ) ] # Return the resulting error code: Exit Script [ $ErrorCode ]
This will create the alias based on the field contents. With the sample data the alias AliasToFolder will be created on the desktop and link back to the Report Folder.
Used in example file
Related script step