How to enable long file paths in Windows

Case #

You get errors whenever you try to save, edit or copy a file or folder whose total path in Windows is longer than 260 characters.

Solution #

Windows operating systems #

The following procedure enables long file paths at the operating system level.

  1. Run regedit and edit the following registry key/value.
  2. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem (LongPathsEnabled=1, DWORD value)
  3. Reboot the machine.

Long file paths are not supported in Windows file explorer by design. Even though the core operating system supports long file paths, Windows File Explorer does not. For the time being (as of April 2024), until Microsoft provides a permanent fix, the following workarounds apply:

  1. Decrease the total path length to be less than 260 characters. For file/folder path shortening, you can use the subst command, as documented at https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/subst.
  2. Make use of a third party free file explorer application which supports long file paths natively, such as https://www.altap.cz/.
  3. There are a few more workarounds which are discussed at: https://answers.microsoft.com/en-us/windows/forum/all/unable-to-rename-folder-or-file-in-a-long-path/f017611d-f99b-49f6-ba4c-dfeddaff5531.

We are hoping that in an upcoming release of Windows/File Explorer or a Windows Update, Microsoft will soon address the above issue.  

SharePoint Online #

Regarding Sharepoint Online, the following applies. The entire decoded file path, including the file name, can't contain more than 400 characters for OneDrive, OneDrive for work or school and SharePoint in Microsoft 365. The limit applies to the combination of the folder path and file name after decoding. Review the following article for more details: Restrictions and limitations in OneDrive and SharePoint - Microsoft Support.

Identifying files and folders with long path #

You can run a simple CMD piped command.

dir /s /b | sort /r /+261 /o out.txt

Or a Powershell cmdlet.

Out-File longfilepath.txt ; cmd /c "dir /b /s /a" | ForEach-Object { if ($_.length -gt 250) {$_ | Out-File -append longfilepath.txt}}

Alternatively you can run a free GUI tool which automates this process even further. Read more at https://github.com/deadlydog/PathLengthChecker. You can download the tool from: https://github.com/deadlydog/PathLengthChecker/releases. Another handy tool which does similar job is TLPD: https://sourceforge.net/projects/tlpd/.

Powered by BetterDocs