I've noticed that Linux symlinks don't work in Windows, and vice-versa. Is there any way to convert Linux symlinks to Windows symlinks? Specifically, I want to convert relative Linux symlinks to relative Windows symlinks (in case the folder with the symlinks is stored on a flash drive, or copied from a Linux filesystem to a Windows filesystem).
-
2Basically, this question is asking whether it's possible to generate Mac and Windows symlinks on Linux, since creating cross-platform symlinks doesn't appear to be possible. – Anderson Green Jan 05 '13 at 21:24
-
1I'm a bit surprised - why did two people vote to close this question? – Anderson Green Jan 06 '13 at 01:42
-
I wish I could move this question to unix.stackexchange.com, since it would be more relevant there. :/ – Anderson Green Jan 06 '13 at 01:47
-
There are some search results about converting Linux symlinks to Windows symlinks: https://www.google.com/#hl=en&safe=active&tbo=d&output=search&sclient=psy-ab&q=convert+linux+symlink+to+windows&oq=convert+linux+symlink+to+windows&gs_l=hp.3..33i29.1313.6140.0.6240.32.32.0.0.0.0.220.3981.10j20j1.31.0.les%3B..0.0...1c.1.saNvCHzokTc&pbx=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&bvm=bv.1355534169,d.dmQ&fp=df08fc36998c1ff1&bpcl=40096503&biw=1366&bih=631 – Anderson Green Jan 06 '13 at 02:41
-
@kojiro Would there be any way to migrate the question (along with the comments) there? I don't want to lose the comments that I've posted here. – Anderson Green Jan 06 '13 at 02:44
-
I'm interested in this question but am a little unclear because these days I'm (mostly) a linux user. I wasn't aware windows had symlinks. Are you referring to symlinks under cygwin or something else. Thanks for your time and sorry for my ignorance on this. – Philip Couling Jan 06 '13 at 13:37
-
More context please. Are you talking about a dual-boot machine, or over the network, or removable disks, or something else? Are you willing to write your own code or do you want an existing tool? – Harry Johnston Jan 07 '13 at 01:26
-
@HarryJohnston I'm willing to write my own code, definitely. I'm working with a dual-boot machine. – Anderson Green Jan 07 '13 at 01:27
-
@HarryJohnston The file system is ext4. Would it be possible to create symlinks on Linux that would be portable from one ext4 filesystem to another? – Anderson Green Jan 07 '13 at 02:40
-
@HarryJohnston I'm reading the ext4 filesystem from Linux, instead of Windows. It is the local filesystem, and I'm trying to create shortcuts for Windows on Linux, based on Linux symlink files. Is it possible to create portable Windows symlinks, by any chance? (I mean symlinks that would link to a relative file path, instead of an absolute file path). – Anderson Green Jan 07 '13 at 02:43
-
1Please clarify: do you want to create shortcuts, or symlinks? If they're being created on an ext4 volume, which Windows can't read, what's the point? Put another way, how are they going to eventually wind up being seen by Windows? – Harry Johnston Jan 07 '13 at 02:46
-
@HarryJohnston Sorry for the typo: I meant "symlinks", not "shortcuts". Also, I would most likely copy the file from the Linux filesystem to Windows using Linux, instead of using Windows (since Linux can read both NTFS and ext4 filesystems, while Windows cannot.) The symlinks should be relative to the folder path, instead of absolute (if this is even possible - I really wish I'd done more research on this subject before posting this question). – Anderson Green Jan 07 '13 at 02:53
-
let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/6999/discussion-between-anderson-green-and-harry-johnston) – Anderson Green Jan 07 '13 at 03:04
1 Answers
Windows doesn't have symlinks per se. It has shortcuts, which are little more than special text files containing a destination location. They differ in features from symlinks. For example, this redirection on a POSIX system (including OS X):
./somecommand > ./somesymlink
will put the output of the command into whatever file the symlink points to, but on Windows
somecommand > someshortcut.lnk
would simply overwrite the shortcut – you'd end up with a text file with a confusing extension.
On the other hand, Windows shortcuts can contain commandline arguments that change the actual nature of the command. Symlinks don't have this capability (though with shell aliases, functions and scripts, you don't really miss it.)
That said, you can create a shortcut file programmatically on Windows, so you can create a script that will try to create the right file for your platform.
- 247
- 1
- 16
-
Would it also be possible to generate a shortcut file for Linux on Windows? I hope it would be possible to generate Linux symlinks from Windows shortcuts, and vice versa. – Anderson Green Jan 06 '13 at 21:53
-
8As well as shortcuts, Windows also has symbolic links, junction points, and hard links. They tend to stay hidden under the covers, as it were, but they exist. – Harry Johnston Jan 07 '13 at 01:25
-
8Symlinks actually do exist in Windows. See here: http://superuser.com/questions/253935/what-is-the-difference-between-symbolic-link-and-shortcut – Anderson Green Jan 07 '13 at 03:16
-
1As of Windows Vista you can create symlinks using the 'mklink' command see: https://en.wikipedia.org/wiki/NTFS_symbolic_link – JamesBarnett Jan 07 '13 at 03:41