What are the rules to avoid max file path lengths?

I am using Windows 10 and have gotten in the habit of sometimes creating very long note names as part of my workflow.

I may be wrong, but from what I understand, reaching an unusable file because of path length obviously deals with both its file name and file path.

Is there a good system I can adopt to try to avoid the day where suddenly, unknowingly my notes stop working because I finally reached that limit. Of course, I know I can just limit length and folder name lengths, and nesting; but, I am trying to find the barrier of problems, so I can cozy up to it safely and confidently.

Even if you can’t give me a solid answer, any sort of pointing in the right direction would be very helpful.

Thank you very much.

If you’re using Windows 10 Pro or Enterprise you can use the Group Policy Editor to disable the MAX_PATH character limit. You can open the Group Policy Editor by opening the Start menu and typing gpedit. The setting is called Enable Win32 Long Paths and is located at Computer Configuration -> Admin Templates -> System -> Filesystem.

MAX_PATH is otherwise 260 characters.

Another option is to create a junction, which is a type of symbolic link. Think of it as a wormhole in your filesystem. You can create a junction from a deeply nested subdirectory to one, say, at the root of the drive. Accessing the latter takes you to the former.

To create a junction you need to open a administrative command prompt. The command looks like this:

mklink /J D:\MyStuff D:\My\Very\Crazy\Long\Path\To\My\Stuff

Now, accessing D:\MyStuff takes you to D:\My\Very\Crazy\Long\Path\To\My\Stuff, but the path will remain D:\MyStuff.

Edit: It’s late and I got my folders backwards.

1 Like

Thanks. This is so helpful. Very cool. Very, very cool, especially about the junction, which I will probably revisit regardless of how things go in gpedit.

I wanted to just respond with gratitude even though I am really just setting out on making this change.

To test, I tried creating and copying a filename with exactly 260 characters and my system just wouldn’t allow me to paste it into rename the already created file. It was then clear to me, I obviously didn’t already have that setting enabled, which was good. This was confirmed when I went into gpedit.

I was then confused when I tried pasting a file name that was 258 and it appeared to work. However, upon further inspection, I realized it had automatically shortened the name to 198 characters. With the file path added, it came to a total of 247, and I am sure there is a reason why those other unlucky 13 characters weren’t pasted, but I am not too concerned.

Anyways, I am now feeling confident enough to, after a little more experimenting and research, try changing this “Enable Win32 long paths” setting that you told me about.

I just went for it and changed the setting then experimented with pasting a 275 character name into that same file and this time it shortened it to 207 to get a total of 256. Now I am guessing this might have more to do with the actual rename functionality, and that the ability to create these long filenames is now there under the right circumstances.

Hmmm. Unfortunately, I just pasted a 275 character name into the title of a new note in Obsidian and it flashed that long ENOCENT warning.

When I get to the bottom of this, I will return.

As a side note, It appears that there really is no issue of grave concern going super long with file names. I guess it all depends on how the software you care about handles these files. My only worry would be that I have valuable information (not backed up) in one of these long files and somehow an operation in Obsidian or elsewhere automatically and discretely shortens it permanently.

Again, thanks for the informative response. It meant a lot. I am well on my way.

You’ll always have a drive letter, colon, root slash and terminating null character, so whatever the limit is the useable length will always have to include those 4 characters.

Removing the MAX_PATH limit is one solution, and junctions are another, but you’ll always have to consider how software is going to behave with those changes. The reason the 260 character limit still exists as an artificial limit is to enforce backwards compatibility with Windows software old enough to still expect it. There could even be some modern software out there that might behave oddly if MAX_PATH is > 260.

Frustratingly, the most “forward-thinking” solution really might just be adjusting your style of note-taking. Hopefully you can find a middle-ground.

1 Like

Just wanted to return here to share a workaround for anyone who struggles with file name length limits.

Headings!

Can’t believe I didn’t think of this sooner.

As far as I know, there is no limit to heading name length.

It does pain me that heading links are not updated when you change the heading, although I have seen requests for this. But at least they are still linked to the correct file.

You could just take care to fix all links to the heading when you edit it. And I guess if you forgot to do this and came across one and knew there were many more, you could open the local graph and filter to only incoming links and have a search filter also for the old wrong heading name links, and fix them one by one. Not sure if there is mass search and replace that works for this in Obsidian, but am sure I have heard about VSCode and many others having search and replace at a folder level.

Anyways, sorry if this is unclear, but I just felt compelled to put this out there because, for me, sometimes having ability to create extra long links is just a necessity.

Thanks.