4

How can we share links to windows file system locations so they work in Windows, Linux and Macs when possible.

This is about a format that works accross platfoms (windows: \server\share\file or often DriveLetter:\file vs. Linux smb://server/share/file) as well as how to generate the links easily.

Alex
  • 1,437

3 Answers3

5

Use URI

scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment]

Proper Syntax

For the UNC Windows file path

\\laptop\My Documents\FileSchemeURIs.doc

The corresponding valid file URI in Windows is the following:

file://laptop/My%20Documents/FileSchemeURIs.doc

File URIs in Windows


Unix

Here are two Unix examples pointing to the same /etc/fstab file:

file://localhost/etc/fstab
file:///etc/fstab

Windows

Here are some examples which may be accepted by some applications on Windows systems, referring to the same, local file c:\WINDOWS\clock.avi

file://localhost/c:/WINDOWS/clock.avi
file:///c:/WINDOWS/clock.avi

https://en.wikipedia.org/wiki/File_URI_scheme

You can use some scripts like this to convert those backslashes or just manually edit them

Alternatively use Path Copy Copy which allows you to copy various types of names like short name, long name, folder name only, file name only, UNC path... You can even create your own type of path to copy with a regex

Path Copy Copy

phuclv
  • 30,396
  • 15
  • 136
  • 260
1

The best solution seems to be to copy a file on a Windows share and then use Ctrl+K in Outlook (insert hyperlink).

This makes as file like S:/myfile.txt to file:///server/share/myfile.txt

Such a link should work across systems.

Pretty cool :-)

phuclv
  • 30,396
  • 15
  • 136
  • 260
Alex
  • 1,437
1

I did something like this for myself, but never could get the link to open explorer on the directory or file. Looked up and down how to enable allowing my email client (an old thunderbird) to open file links with the default app, but no luck. The HTML works if I past the link into the windows 'run' box -- so windows will open the the link with the correct application. Had expanded it from there but I have cross client+server links that work so it wouldn't be hard to do the rest. But it depends on getting the links to open in my email client: `

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head></head>
<body bgcolor="#f8e8ff" text="#004040">

<br /><a href="file:///T:/Library/_CurrentSeason/_Kenja no Mago/[HorribleSubs] Kenja no Mago - 12 [720p].mkv">T:/Library/_CurrentSeason/_Kenja no Mago/[HorribleSubs] Kenja no Mago - 12 [720p].mkv</a>
<br /><a href="file:///T:/Library/_CurrentSeason/_Tate no Yuusha no Nariagari_;_herosSaveDay/[HorribleSubs] Tate no Yuusha no Nariagari - 25 [720p].mkv">T:/Library/_CurrentSeason/_Tate no Yuusha no Nariagari_;_herosSaveDay/[HorribleSubs] Tate no Yuusha no Nariagari - 25 [720p].mkv</a></body></html>

`

The links work, on Windows, and was mailed to me by a linux script that runs periodically and sends me notifications. I don't have a desktop on linux (I run 'X', that displays on my Win machine). But trying to open the link on linux would be pointless (as it has no desktop nor good media handling), and Mac would be more pointless as I don't have that.

I do have file system links that work on linux, and on windows, but not sure if that's useful... All of these things, though, are unique to my setup and my paths. So I'm a bit confused as to what you are actually wanting.

Don't try to open URL links with backslashes in them. Windows uses forward slashes for URL's. Also, you can't have the same links on each system unless their file systems have a similar structure. However, you can use symlinks to get around that.

Some examples from Cygwin/Windows/linux on my Windows root dir:

cygwin: (/)
D/
Documents -> //Bliss/Documents/
M/
Share -> /S/
S/
T/

windows DIR (c:)

D -> /??/UNC/Bliss/Documents
Documents -> /??/UNC/Bliss/Documents
M -> /??/UNC/Ishtar/Music/Anime
P -> /??/D:/Pictures
Share -> /??/S:/

linux: (/Athenae)
D -> /??/UNC/Bliss/Documents/
Documents -> /??/UNC/Bliss/Documents/
M -> /??/UNC/Ishtar/Music/Anime/
P -> /??/D:/Pictures/
S/
T/

The plain 'S/' can be viewed on any of the above with Cyg+win using /s/ and on linux '/Athenae/S' (S is really a linux dir /Share, so going through /Athenae/S goes to the windows workstation to get the files which asks for them from the linux box.

Since some of the windows links use /??/, I created a directory on linux with the name of 2 question marks: ??/, so on linux

> ll '/??/UNC'   #gives:
lrwxrwxrwx 1  6 Feb 28  2015 Bliss -> Ishtar/
drwxrwx--- 2 61 Feb 28  2015 Ishtar/
lrwxrwxrwx 1  6 Feb 28  2015 ishtar -> Ishtar/

that way, windows links being shown on linux will take me to the right place.

All that symlink mumbo-jumbo is to make the same pathname work on my linux and on my windows box (which was part of your question), as it was my way of making sure the file-path portions of things could be seen from the same pathnames.

To do what you want can be complicated unless you force some simple common directories to be the same on every system.

To open the links in email...ARG....I don't know how to override the security restrictions, as the link, when copied from the email into the WIN-R (Run prompt) works correctly.

Anyone with an idea of how to get a local link to open in email (something that should have been possible enabling the file proto, but that didn't work. (sigh).

Astara
  • 659