Files.CreateAlias
-----------------

Creates an alias or link file.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Files](component_Files.md) | [8.4](newinversion84.md) | ✅ Yes | ✅ Yes | ❌ No | ✅ Yes, on macOS and Windows | ✅ Yes |

MBS( "Files.CreateAlias"; AliasFilePath; TargetPath { ; RelativeTo or WorkingPath; IconPathAndIndex } ) 

**MBS**( **"Files.CreateAlias";** /\* Creates an alias or link file. \*/  
**$AliasFilePath**; /\* The path for the alias file path.e.g. "/Users/cs/Desktop/test" \*/   
**$TargetPath**; /\* The target path to have the alias point to.e.g. "/Users/cs/Desktop" \*/   
**$RelativeTo or WorkingPath**; /\* Optional; The folder path to use relative resolution for Mac or the working directory for Windows.e.g. "/Users/cs" \*/   
**$IconPathAndIndex**) /\* Optional; The icon file path to use.  
Optionally with an index as second item in a value list.  
  
For Windows must reference an exe, ico, dll or similar file containing resources with icons.  
  
For MacOS a path to an image file where we load image and use it for the icon.e.g. "C:\\Program Files\\Mozilla Firefox\\firefox.exe¶4" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| AliasFilePath | The path for the alias file path. | "/Users/cs/Desktop/test" |  |
| TargetPath | The target path to have the alias point to. | "/Users/cs/Desktop" |  |
| RelativeTo or WorkingPath | The folder path to use relative resolution for Mac or the working directory for Windows. | "/Users/cs" | Optional |
| IconPathAndIndex | The icon file path to use.   Optionally with an index as second item in a value list.      For Windows must reference an exe, ico, dll or similar file containing resources with icons.      For MacOS a path to an image file where we load image and use it for the icon. | "C:\\Program Files\\Mozilla Firefox\\firefox.exe¶4" | Optional |

### Result

Returns OK or error.

### Description

Creates an alias or link file.  
If relative path is provided, the alias will include the relative path from that folder to the target item. When resolved later and the full path is invalid, the relative path may find it.  
  
See [Files.CreateSymbolicLink](FilesCreateSymbolicLink.md) for creating symbol links and [Files.CreateHardLink](FilesCreateHardLink.md) for hard links.  
  
Testing in macOS Catalina shows for us, that the icon can be added, but the Finder does not display it.  
  
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

Create Alias:

 MBS ( "Files.CreateAlias"; "/Users/cs/Desktop/test"; "/Users/cs/Desktop" )  
Creates link files on Windows:

 MBS ("Files.CreateAlias"; "C:\\Users\\Christian\\Desktop\\test.lnk"; "cmd.exe")  
Create link for image file:

 MBS ("Files.CreateAlias"; "C:\\Users\\Christian\\Desktop\\test.lnk"; "C:\\Users\\Christian\\Pictures\\test.jpg")  
Create link file with icon on Windows:

 MBS ("Files.CreateAlias"; "C:\\Users\\Christian\\Desktop\\test.lnk"; "cmd.exe"; ""; "C:\\Program Files\\Mozilla Firefox\\firefox.exe¶4")  
### See also

- [Files.CreateHardLink](FilesCreateHardLink.md)
- [Files.CreateSymbolicLink](FilesCreateSymbolicLink.md)
- [Files.ResolveAlias](FilesResolveAlias.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)

### Release notes

- **Version 9.2**
    - Added new parameter for [Files.CreateAlias](http://www.mbsplugins.eu/FilesCreateAlias.shtml) to specify icon for the alias/link file.
- **Version 8.4**
    - Added [Files.CreateAlias](http://www.mbsplugins.eu/FilesCreateAlias.shtml) and [Files.ResolveAlias](http://www.mbsplugins.eu/FilesResolveAlias.shtml) functions.

### Blog Entries

- [MBS Plugin Advent calendar: 12 - Files](https://www.mbsplugins.de/archive/2023-12-12/MBS_Plugin_Advent_calendar_12_/monkeybreadsoftware_blog_filemaker)
- [Customize your FileMaker solution](https://www.mbsplugins.de/archive/2021-04-25/Customize_your_FileMaker_solut/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 9.2pr1](https://www.mbsplugins.de/archive/2019-04-02/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 8.4pr8](https://www.mbsplugins.de/archive/2018-09-13/MBS_FileMaker_Plugin_version_8/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

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

This function checks for a license.

Created 9th September 2018 , last changed 28th September 2020

  
[Files.CopyFiles](FilesCopyFiles.md) - [Files.CreateBookmark](FilesCreateBookmark.md)

[HTML Version](FilesCreateAlias.shtml)