Relative - Relative shortcuts for Windows

Share interesting information or links related to portable apps here.
Post Reply
Message
Author
lautrepay
Posts: 715
Joined: Sat Mar 26, 2011 2:31 am

Relative - Relative shortcuts for Windows

#1 Post by lautrepay »

Website: http://www.csparks.com/Relative/
What is this thing?
Relative lets you create relative shortcuts in Windows. As the name implies, relative shortcuts can be moved along with their parent directory tree and still point to the same location within the tree.
The current version of Relative works with Windows XP, Vista, and Windows 7. It's too painful for me to look at Windows 8 in order to test the program, so please let me know if that works.

Usage
Right-click on any file or folder. From the context menu, select "Create relative shortcut...". A file browsing window will appear. Navigate to the location where you want to create your shortcut and click "Ok".

Command line usage
If you put the installation directory on your PATH, you can use the program from the command line:

Code: Select all

relative targetPath shortcutPath
For example:

Code: Select all

relative a/b/c/someTarget.txt a/b/d/myshortcut
The relative shortcut path in this case would turn out to be:

Code: Select all

../c/someTarget.txt
Limitations
If you move the shortcut file or the target file, the shortcut obviously won't work. You can modify the shortcut path from its Properties panel, but it's usually easier to create a new one.
You can't create a shortcut to a file that doesn't have an associated program of some kind. In other words, if you can't double-click on a file and open it with something, you won't be able to create a relative shortcut.
Although you can create shortcuts using the command line, they are only usable from Explorer. You can't, for example, use one as a parameter to another command that expects to operate on the target.

The program doesn't support Windows unicode (UTF16) filenames yet, but I plan to do that Real Soon Now.

What's wrong with "mklink"?
Starting with Windows Vista, there is a command line function:

Code: Select all

mklink newSymbolicLink targetPath 
If you try this, it appears to do exactly what Relative does (only with the parameter order reversed.) If you move a symbolic link to another location where the relative path makes sense, it will work there as well. And symbolic links can be used as parameters to other commands, unlike the shortcuts created by Relative. So what's not to like? Unfortunately, at least two big things:
  • If you copy symbolic links with Explorer or a directory tree that contains such links, the link files that should be in the copy are replaced by their targets! This is a fatal design flaw.
  • If you backup Windows machines with a remote linux file server, symbolic links are copied as zero-length files with no information about how to recreate them when the backup is restored. Of course, that's just a limitation of Samba on Linux. So next I tried using Microsoft's backup program that comes with Windows 7. I created a small tree of files and folders that contained some symbolic links and backed them up. Then I restored the backup to another location. The result was such a mess, I'm at a loss for words to describe it.
It seems that the Windows developers wanted to have something like linux symbolic links, but since they are trained in a bubble universe, had no accurate conception of how they're supposed to work.
Download: http://www.csparks.com/Relative/RelativeSetup-0.92.exe

User avatar
guinness
Posts: 4118
Joined: Mon Aug 27, 2007 2:00 am
Contact:

Re: Relative - Relative shortcuts for Windows

#2 Post by guinness »

Useful for those who lack or have limited knowledge in how to create relative paths. If I need to go quite deep then I use AutoIt and the function _PathGetRelative() to ensure I haven't messed up.

User avatar
Midas
Posts: 6725
Joined: Mon Dec 07, 2009 7:09 am
Location: Sol3

Re: Relative shortcuts or links on Windows

#3 Post by Midas »

Nice find, lautrepay -- one can't have too many solutions for the many 'papercuts' of our platform of choice... ;)

FTR, another relevant TPFC debate on this topic can be found at viewtopic.php?t=3640 -- see especially what I posted at the end viewtopic.php?p=65410#p65410 ...

BTW, Relative is currently v0.95 (no changelog).

Post Reply