Alias or symlink with a RELATIVE path?

Is there a simple way to create an alias or symlink with a RELATIVE path to its target? I'd like to create an alias or symlink that points to a file inside a folder and create it so it will work on anyone's Mac. Thanks!

MacBook, Mac OS X (10.6.6), Core 2 Duo

Posted on Apr 29, 2011 6:46 PM

Reply
10 replies

Jul 29, 2016 10:54 AM in response to highmeadow

Bash auto-expands paths BEFORE passing them on to programs you're executing.

Thus, "~/filename" -> "/Users/username/filename", and "../filename" -> "/path/to/cwd/../filename" -> "/path/to/filename".


You can tell Bash not to auto-resolve the path by simply enclosing it in quotes.


// this will create an absolute symlink, even though you wrote a relative path, because of auto-expansion

ln -s ../..somedir/filename filename


// this, on the other hand, will create a relative one

ln -s "../..somedir/filename" filename

May 20, 2011 4:41 AM in response to highmeadow

I was mastering a CD ROM with an Alias on the root-level that points to a flash-application in a folder on the CD. When copied from CD to the Desktop, the copied alias points to the application on the CD. The CD ejected, the Alias-Dialog sais that it can not find the orignial. Because it doesn't find the CD-Volume anymore.


So I tried to use a symbolic link, that uses a relative path to make the connection to the orignial. Symbolic links work on HFS+, on UDF-DVDs, but they can't be used on a Hybrid-CD-ROM.


Solution:

Before Mastering, create an Alias of the original application. Make a copy of the original application. (same hierarchy) Delete the original Application an rename the copy with the original name. Test the alias. (Don't use the function to update the connection to the original!) The alias makes know the connection by a relative path. The structure can now be copied to a new place or volume and the alias alway finds the copied original.


When the original program is deleted, the Alias looses the connection by the internal file-ID an replaces it trough the relative path. This hint helps distributing structures with Aliases by CD-ROM.

Apr 18, 2012 8:07 AM in response to highmeadow

Hello guys


Interestingly enough, we have just solved this problem. You simply need to go in the terminal and create a symbolic link the old fashion way.


You need to change directory to the folder where you need the alias to be using cd. Then use the ln command to create the symbolic link


# ln -s existing-link-target name-of-the-think


It works pretty well for us. We have made the following tests to verify that the symbolic link (the "alias") works as excepted:


  1. We have copied the link elsewhere. We immediatly noticed that the icon was no longer showing nicely and that double-clicking on it shows that it was broken.
  2. We have double-clicked on the icon on the USB key (or CD) and it worked.
  3. In the case of the USB key, we have changed the volume name and it was still working.
  4. We tried the application on other Macs with success.


I hope this helps


Cheers

Jul 22, 2012 7:55 AM in response to asiby

Thanks Hansueli.


I need to burn a folder to a CD-ROM using Toast. Inside this folder is an alias of the application and another folder with all the data and the original of the application (Director Projector). The alias is supposed to execute the projector in this flde whch it doe son my hard disk. like Higheadow, Each time I copied the folder, the alias no longer linked to the app inside the folder sitting adjacent to it.


I am very anxious to try your method. I have not found any thing that would maintain the relative paths, so your suggestion is very helpful. Thank you ahead of time.

Jul 29, 2012 5:47 AM in response to charapp

Hello,

a crucial step in my procedure seems to be "Test the alias". After the alias has not found the original file, it is ready to accept a relative path. This path will be created when the alias finds a copy of the original file with the original name at the same position.

In the meantime I have mastered several CD-ROMs using this procedure.


Hansueli

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Alias or symlink with a RELATIVE path?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.