Make a symbolic link with Shell on Mac Win Linux

Hi,
I test before if the original item exists and if an item with the name doesn’t exist in the Destination folder. Then I assume all is ok.

Dim MyOrgItem as FolderItem -- I want an Alias which point to this file Dim MyDestFolder as FolderItem -- I want my Alias to be in that folder Dim TextCdeShell, NameAlias as String Dim CdeShell as New Shell
If I want to give a different name I do

NameAlias = "/TotoNewName"

If I want to keep the same name

NameAlias = ""

I know how to do with Mac OS and I can test as it is my System :

TextCdeShell = "ln -s " + MyOrgItem.ShellPath + " " + MyDestFolder.ShellPath + NameAlias CdeShell.Execute TextCdeShell
On Linux, I don’t know but I suppose it’s the same.
On Windows, I search on the web and as far as I understood :

If MyOrgItem.Directory Then TextCdeShell = "mklink /D " + MyDestFolder.ShellPath + NameAlias + " " + MyOrgItem.ShellPath Else TextCdeShell = "mklink " + MyDestFolder.ShellPath + NameAlias + " " + MyOrgItem.ShellPath End If CdeShell.Execute TextCdeShell

Attention : a symbolic link on Mac is not the same as an alias. You can move the target of an alias, and it will still resolve. Not a symbolic link.

indeed the syntax of ln is exactly the same on Unix and Linux.

Thank you Michel. That’s why, I suppose, on Mac an Alias is so heavy (1 Mo) and a Symbolic Link is 10 ko.

If someone can tell me if i’m good on Windows.

I can’t help with Windows but I wanted to clarify that if you create a hard symbolic link (rather than a soft link, which is similar to an alias), then you can move the original target of the link, or even delete it, with no ill effects.

on shell, it’s simply ln command. use “man ln” in Terminal to read manual.

Or use NSFileManagerMBS and the createSymbolicLink method. Or linkItem for hard link. And destinationOfSymbolicLinkAtPath resolves them. Can be used easily with MBS Plugins or you write yourself a few declares for that.