Long paths
Introduction
The maximum length of paths and file/folder names is limited in every mainstream operating system and file system. The exact limits can vary significantly between systems.
For example, in Windows 10 and earlier versions the maximum path length is limited to 260 characters (MAX_PATH constant). In contrast, Linux imposes a limit of 4096 bytes for full paths and 255 bytes for file names. Older systems imposed even stricter limits, like DOS with an 80-character limit for full paths and only 12 characters (8.3 format) for file names.
Fortunately, this issue is slowly but surely being addressed, in one way or another. The sections below also discuss ways of working around some of these limitations.
Long paths in Windows
Modern versions of Windows have an alternative file path specification mechanism that overcomes the 260 characters limitation.
Consider a conventional file path:
C:\Very\Long\Path
To convert a path to the "long path" specification, prepend it with \\?\, as follows:
\\?\C:\Very\Long\Path
This effectively raises the maximum path length to 32,767 characters, and also enables paths that end with a dot.
However, there are other potential limitations to be aware of:
- This only raises the limit imposed by the Windows operating system; limits imposed by individual file systems may still apply.
- Support for long paths also depends on the capabilities of individual applications.
Native long path support in Windows
On Windows 10 version 1607 and later, long paths can be enabled natively. This requires two conditions to be met:
-
The application's manifest must have the Long Path Aware feature enabled:
<ws2:longPathAware>true</ws2:longPathAware> -
The system must have the
LongPathsEnabledregistry entry set to1(DWORD):HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled
A reboot, or a log off and log back on, may be required for the changes to take effect.
Once enabled, the maximum path length extends to approximately 32,767 characters, without the need for the \\?\ prefix.
Long paths in ReNamer
ReNamer normally operates with conventional file paths, but it can also handle the "long path" specification if one is provided.
The standard Add Files and Add Folders dialogs cannot handle long paths. However, you can use the Add Paths dialog from the main menu, or the Export/Import menu options.
Truncating long paths
Excessively long paths can make files inaccessible to some applications, including Windows File Explorer itself.
A common workaround is to truncate long paths. This can be achieved using the Pascal Script and Regular Expressions rules.