GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Symbolic links TO 256 character dirs

Hi,
@Dopus: If possible, please make it possible in a future version that the program does not use the Windows API - but an own program routine/code directly from Dopus - to create symbolic links and that therefore symbolic links from directories/files with more than 256 characters TO directories with more than 256 characters are only possible in a very complicated way (currently, this is only possible in directories with more than 256 characters if you create the symbolic link in a directory with few characters - e.g. C:\Links - and then move the symbolic links created here into the desired directory with more than 256 characters).
Or is there already a tinkering possibility or a script?
Thanks Alexander

That doesn't really make sense. Links, and anything else in the filesystem, must be created using the Windows API or nothing else would understand them. We would have to create our own filesystem or disk format to do something out of spec.

But I'd be surprised if symlinks are really limited to 256 characters anyway. You can usually bypass path limits by prefixing \\?\ at the start of the path. However, this is not generally a good idea unless you really need to do it, or are working on paths that are already that long (Opus will do it for you automatically with those), because some things will have problems with such long paths. Avoiding the need in the first place is the best solution.

Hi Leo, thanks for your answer.
Yes, symlinks seem to be limited to 256 characters.
This is exactly my problem.
Maybe you can (1) give the Windows API -> short path information of the long (target!) directory directory, (2) the Windows API then creates a symlink with short directory path information and (3) Dopus then "translates" the short directory path information of the Windows API back into long directory path information?
I have been linking long directories to extra drives with the "subst" command for many, many years anyway, but even then the problem with creating symlinks still occurs under DOPUS ...
And I always create a symbolic link (quickly) with the right mouse button -> create symbolic link, usually in the same directory and then move it to the target directory (with more than 256 characters). Here I cannot specify \?. - But also the source directory is, together with the filename, already longer than 256 characters, so that already here the symbolic link is created only with a shortened filename and also shortened content in the link properties.
Meanwhile, many programs support more than 256 characters in directory paths and file names together, so that this has never been a problem for me and I have been working this way for many years.

That isn't an Opus command, at least by default. Maybe you've added it to the context menus, but it could also be a third party thing. e.g. Link Shell Extension is quite popular for creating symlinks via the context menus.

I just tried creating a symlink using Opus itself and it works just fine creating something that points to a folder with a 262 character long path.

So I don't think there is an actual issue with Windows or Opus here, just with whatever you're using to create the links.

Edit:

To clarify, I created a link TO a folder with a very long path. The link was created IN a folder with a short path length. I assume that's what you're doing, as a way to create shorter names for things with overly long paths.

I used the commands which are, by default, in the Copy Files > Create Advanced Links menu of the default toolbars.

First of all: Clicking on advanced links, where several choices appear, I always get an error, especially that the (source) directory is not found (the path length together with the file name of the file I want to link is 297 characters). Maybe this is because this directory is a directory on a "subst" drive?
Is there perhaps a dopus key combination for this?

Unfortunately, I don't know whether this comes with the right mouse button from a third program.
By the way: Yes, as I wrote above: The link creation IN a folder with kurer(!) path length works wonderfully.
BUT I would very much like to create a link into a folder with a path length of more than 256 characters (from a source folder that also has more than 256 characters). I do NOT want to create short names [because the names should already describe a lot in the file ;-)].

Creating a symlink to something in a subst drive probably will not work.

You can add hotkeys to menu items by editing the menus. (e.g Settings > Customize Toolbars, then double-click the thing you want to edit.)

Then I think you should reevaluate what you're doing because unless you're creating these symlinks to make shorter paths to avoid the problems of longer paths, you WILL run into problems with various software, APIs and libraries from such long paths. Just don't do it, is my advice. Clean things up so the paths are shorter, and if you're using folder names to store metadata, move it to somewhere more appropriate.

I am talking about symlinks of files and not of folders. So I don't want to create more or less than one symlink from an e-mail (*.msg), which is located in a folder with more than 256 characters (together with the e-mail name), to another folder with more than 256 characters (together with the name of the e-mail) ... because in this target folder there are also files, for which the topic of the e-mail is also interesting.
So, it's not about making anything "shorter", I just ONLY want to avoid making copies with symlinks.
So why shouldn't that work with Dopus, after my above mentioned idea [=» Maybe you can (1) give the Windows API -> short path information of the long (target!) directory directory, (2) the Windows API then creates a symlink with short directory path information and (3) Dopus then "translates" the short directory path information of the Windows API back into long directory path information?]?

You could try doing the same thing at the command line using the mklink command to see if it works.

It's not really something we want to encourage, though, because if you solve this issue then you'll just run into 5 more issues afterwards, because extremely long paths cause all sorts of problems with all sorts of software. It's best to just avoid the situation in the first place, unless something is really forcing it to exist (e.g. software creating those folders in a way which you cannot change or control).

"mklink" has disadvantages compared to subst drives, among other things because you cannot assign other icons to the directories.

The "problem" exists only with Windows (and e.g. not with Linux). This is because Microsoft hasn't done its homework for decades and is slow to open the NTFS support of 32,000 (!) characters. "All kinds of problems with all kinds of software" does not exist with me, because I only use software that supports more than 256+ characters (that's why I bought Dopus).

If you store your files STRUCTURED(!), i.e. in particular upper directories are divided into many subdirectories and these again in each case into many subdirectories and you write the rough contents of the file into the file name, then you have reached very fast 256 characters (characters of the names of the directories and the characters of the file name together).

Yes, you only have this problem, of course, if you have a structured way of thinking (and do not just work with "tags" etc.). - But believe me: I am not the only person who thinks in such a structured way and stores his files in such a structured way.

I think it's a bit crazy that on the ONE HAND with DOPUS you can copy and move files from directories with more than 256 characters (=characters of the directory and characters of the filename TOGETHER) -> INTO directories with more than 256 characters (=characters of the directory and characters of the filename TOGETHER) very well/wonderfully --- which by the way was the main reason why I bought Dopus :wink: ---, but ON THE OTHER SIDE you can NOT(!) create a symlink from a file in a directory with more than 256 characters (=characters of the directory and characters of the filename TOGETHER) -> INTO another directory with more than 256 characters (=characters of the directory and characters of the filename TOGETHER).

Don't you think so, too?

Is there perhaps the possibility of a script that does - with one or two mouse clicks - what I would otherwise have to do MANUALLY, if I want to create a symlink from a file "f1" with more than 256 characters FROM a directory "d1" with more than 256 characters IN another directory "d2" with more than 256 characters:

  1. the first step of the script is to create a symlink of the file D1 into a self - predefined - (short!) directory, e.g. "C:\temp" (which works!);

  2. as second step of the script, this created symlink file with the extension "*.lnk" is moved (this works with DOPUS, see above!) into the original! directory "d1" (with more than 256 characters);

That would be enough for me, because now I could quickly MOVE this newly created symlink file from the original directory "d1" manually INTO the target directory "d2" of my choice ... et voila :wink:

mklink creates links. That is what you are asking for.

If you want to use subst instead of links, knock yourself out, but then I don't understand the purpose of this thread.

If you want to use links, try your idea using mklink to see if it actually works.

If it works, we can tell you how to make an Opus button for it.

You can create structure without creating extremely long file paths that break a lot of software and APIs.

It's your computer, so you can do what you want on it, but we will also be reluctant to help with issues that will probably arise later if you ignore our advice.

(e.g. The Recycle Bin doesn't even work properly in such paths. It's a very bad idea to create them when nothing is forcing you to.)

Clarification of the misunderstanding: I want to use "links" on a "subst" drive (with more than 256 characters).

If the source has more than 256 characters, "mlink" will not work:

Example 01 (Creating a link from a "subst" drive to "C:\short"):

mklink "C:\short\test4" "M:\2019\030114-19\02 STOFFSAMMLUNG - u.a. RECHTLICHE KK mit RAe + MD\03 ab 20-01-21 KK mit MD+RAe -12 bzgl. xxxxxxxxxx + xxxxxxxxxxx\20-06-25¦14.12¦-xxxx-xxxxxxx an xxx+xxxxxxxxx - HIERx xxxxx xxxxxxxx xxx xxxxxxxxxx -» xxxxxxxxx xxxx xxxxxxxxx xxxxxxxx xxxxxxxxxx xxxxxxxx xxxxx.msg"

Example 02 (Creating a link from a "mkdir" directory to "C:\short"):

mklink "C:\short\test4" "C:\xxx\2019\030114-19\02 STOFFSAMMLUNG - u.a. RECHTLICHE KK mit RAe + MD\03 ab 20-01-21 KK mit MD+RAe -12 bzgl. xxxxxxxxxx + xxxxxxxxxxx\20-06-25¦14.12¦-xxxx-xxxxxxx an xxx+xxxxxxxxx - HIERx xxxxx xxxxxxxx xxx xxxxxxxxxx -» xxxxxxxxx xxxx xxxxxxxxx xxxxxxxx xxxxxxxxxx xxxxxxxx xxxxx.msg"

Error EVERYTHING: "Wrong parameter"

BUT: If I press the file in question with the right mouse button pressed and then create a link in 'C:\short' when releasing the mouse button and selecting "Create Links" OR(!) with the command "Create Links" via the DOPUS menu (click from 'Source' to 'Target') ... then in BOTH cases a symbolic link is created correctly in the directory 'C:\short'.
So: Which command does Dopus use when you select "Create Links" via the Dopus menu ('Source' to 'Target')?
If I knew this, maybe I could write a script that creates such a link in the short (temp-)directory 'C:\short' in step 1 and then MOVES this link to the original directory in step 2 (...)

"Create Shortcut" will create shortcuts, not symbolic links. Not sure it's relevant here, unless you actually want shortcuts rather than sym-links.

Have you tried using short paths with the mklink command line? (Assuming short paths are enabled in both the source and target filesystems.) I'm not sure if mklink expands them to their long versions before doing things, but it is worth a try and often provides a way around path length issues.

You should also try prefixing the long paths with \\?\ on the command line, since that also turns off path-length limitations in a lot of cases.

Or just don't do any of this as it will cause you more problems down the road.

Note: I'm probably not going to give any more advice in this thread. I've already said it's a bad idea so many times and you're on your own at this point.

sorry 'shortcut' was a translation error, I have now corrected it in my last post.

with \\?\ the error message "wrong parameter" no longer appears and he also creates a symlink, but this symlink doesn't have enough data, because you can't open the file (unlike when you create a link via the dopus menu with the button "create links", where it works)

O.K., can you at least answer the (last) question that I have already asked, plz: What is the COMMAND that DOPUS uses when you select "Create links" from the Dopus menu? - BECAUSE: This works (see above) ... and the command "mlink" can't be it, because it does NOT work (see also above)!
Thx.

It doesn't run a command, it calls the Windows API for creating links. mklink.exe should call into the same API ultimately.

(Note that you usually need to run mklink.exe from an elevated command prompt to create symlinks.)