Sublime Forum

For Windows shortcuts (.ink) files, Open the file they point to?

#1

I have allot of windows shortcut files (.ink) that point to allot of text and code files. In short windows shortcut files is a big part of how I like to work.

In sublime whenever I try to open a shortcut file either via a right click on the shortcut in explorer or drag and drop on sublime text window it opens the shortcut file itself which are just a bunch of 000 and 111.

This gets even worse when I have a sublime project that has shortcut files. Sublime just open pages of 000 and 111 instead of code!

I know this is standard behaviour but I in this case I really need to open the real files the shortcuts point to. Is there a way to achieve this? Thank you!

0 Likes

#2

I did a bit of research on this, but I don’t see a simple way of doing this. Ideally, a simple event listener with an on_load callback, that would trigger when a .lnk file is opened, reads the file path it points to, opens that & closes the .lnk file should do it, but I haven’t been able to find a simple way using Python to read the file path, the shortcut points to.

The only thing I found is using os.startfile(path_to_lnk_file), but this acts like directly double clicking the .lnk file.

I guess what you could do is always choose ST to open the file with Open With -> Choose Another App, click on ST and have the checkmark on “always choose this app”. That way, when you double click the .lnk file, the target file will be opened in ST.

1 Like

#3
0 Likes

#4

As per above suggestions, I’ve created a plugin for ST>=4105: https://github.com/jfcherng-sublime/ST-FollowLnk

Basically, it’s just https://github.com/jfcherng-sublime/ST-FollowLnk/blob/main/plugin/FollowLnk.py and an external lib.

3 Likes

#5

I wasn’t aware of this library, but looking at the linked repo seems to show that it’s not a trivial task without the library. But I guess it does a lot more than just resolving .lnk files, hence the probable complexity.

1 Like

#7

Thank you so much for this, it works perfectly. Very kind of you to create this plug in

EDIT:

Hey upon further testing; it works in all use cases accept for when using the go to anything bar, sublime still opens the .ink files and shows pages of 00000 11111 343434 45666h6.

I’ve recorded an example of the problem for you

I am so happy that you could devise a solution for this problem, I really need go to anything to work with .ink. Any chance you could take a look at your plugin to see what the problem might be ? Thanks!

0 Likes

#8

Can’t come up with a good solution for that.

1 Like

#9

I see, still it was a great effort on your part and it mostly works. Much appreciated!

0 Likes

#10

I’m really curious, why you keep calling the shortcut files .ink instead of what they actually are, .lnk? :slight_smile:

0 Likes

#11

I also don’t see why working with .lnk files when you can work with actual files.

0 Likes

#12

It looks a bit like there’s a build process involved, and .lnk files are being used to allow basic code reuse - maybe for different targets?

I wonder if replacing .lnk files with symbolic links would rationalise it? Does ST treat symbolic links in the same way as physical files?

0 Likes

#13

I’m really curious, why you keep calling the shortcut files .ink instead of what they actually are, .lnk ?

You see prior to landing here, a French man had informed that they were called .ink. the French are a lowly lot. Thank you for informing better.

It looks a bit like there’s a build process involved, and .lnk files are being used to allow basic code reuse - maybe for different targets?
Imao, you give me too much credit. I am just a lowly animator trying to gather a bunch of .xml files that various software’s write their preferences data to.

Instead having to trawl through various in software GUis I would rather do it in Sublime, efficiently. The only problem is these .xml files are scattered everywhere (Apddata, Program files etc) and importing them into a sublime sidebar creates a mess of a directory tree and files/folders I do not care for.

I wonder if replacing .lnk files with symbolic links would rationalise it? Does ST treat symbolic links in the same way as physical files?
I will look into that term and see what it is. Thanks!

0 Likes

#15

I was able to entirely overcome the issue using soft links or sybmbolic links thanks to @mrsean2k suggestion. Works really nicely now.

0 Likes