Links to files and folders on Mac

In Windows one can right click on a folder or file and copy a link to it, then paste it wherever it’s needed, click the resulting link and open whatever folder or file was linked in its corresponding app.

On Mac OS it’s not in the right click menu, but holding down option key during the right click changes the menu options and allows the link to be copied. However when I try to paste a link, for example command k for the link and then command v to paste, into Notes, a link is created, but clicking on it results in a popup containing “the application can’t be opened -50”. The same thing happened with a file that would normally open in an app.

I tried copying the same link into OneNote; when I clicked the link a dialog appeared informing me that OneNote needed to be granted access to the folder at the link. There was a dialog to grant access to this single folder, and when I gave access, that link now works in OneNote - I can click the link and the folder opens in the Finder.

So, is it possible to grant Notes and or OneNote this permission globally rather than to individual files and folders?

Have you looked at Hookmark?

2 Likes

Thanks but no I have not. This is an app permission issue in the OS, it should not take a 3rd party app to fix it.

1 Like

You can give them Full Disk Access in System Preferences | Security & Privacy.

For places the path alone doesn’t work, you could try prefixing it with file://. Like:
file:///Users/yourname/Documents/novel.txt

2 Likes

Thanks! Inserting file:// before each link works for Notes, and it does not need Full Disk Access.

For OneNote, granting access to the parent folder plus using the file:// prefix works.

Note that I believe file paths prefixed by file:// need to be escaped if they have spaces in them (replace spaces with %20)

1 Like

The OP found an area of macOS that is inexplicably more complicated than it needs to be. Anyone should 100% be able to easily copy a link to a file. macOS should copy that from Windows. Sadly as is, we have to use workarounds.

3 Likes

Further, links should be to the *file * not to where the file is, so that moving files doesn’t break its links. This could be done using UUIDs. If they worked across devices (macOS, iOS), that would be even better. The ultimate would be cross platform as well (macOS, Linux, Windows).

2 Likes

But I think that would require something like the Windows registry – not something Apple is likely to do (and the source of a lot of headaches on Windows as I understand it).

Not sure if Unix has a way of handling it.

1 Like

As I recall OS/2 would automatically update links/aliases when a file was moved to another directory/drive. I think it was using the HPFS file system at that time.

1 Like

I use an AppleScript to output the link to the selected file in Finder, here it is:

tell application "Finder"
	set theItem to the first item of (get selection)
	set theURL to the URL of theItem
	return theURL
end tell

I use it as a text expansion action in keyboard maestro:

I’ve also used it on an Alfred Workflow that can be used as a file action:

on run
	set theQuery to POSIX file "{query}"
	set theQuery to theQuery as alias

	tell application "Finder"
		return URL of theQuery
	end tell

end run

I’ve created a public link to this workflow should anybody be interested into using it.

2 Likes

There’s a similar mechanism behind macOS’s aliases, which still work when the original file is moved around. code

No need to resort to a registry :face_vomiting::slightly_smiling_face:

Cross-device and platform is the tricky bit. There’s probably a distributed file system around somewhere.

3 Likes

Hi, working script for Bookmark / file reference here, hope this helps
Tom’s post on KBM forum

Welcome!
Thanks for the contribution!
Will have a look.