Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Fix File Names Larger Than File System Supports

· 7 min read · Home Tech

In this article
  1. Background: Why File Name Limits Exist
  2. How File Name Limits Work
  3. How to Fix the Error
  4. Common Problems and Misconceptions
  5. How to Check Path Length
  6. Alternatives to Shortening Names
  7. Frequently Asked Questions

If you see an error saying a file name is too long for the file system, the fix is to shorten the file name (or the full path) to fit within the file system's limit. The most common culprit is Windows' 260-character maximum path length, but other file systems have their own limits; you can either rename the file, move it closer to the root directory, or enable long path support in Windows.

Background: Why File Name Limits Exist

File systems impose limits on the length of file names and paths for historical and technical reasons. These limits ensure that the file system's internal structures remain efficient and that software can reliably handle paths without running out of memory or buffer space. The most famous limit is the Windows MAX_PATH constant, which caps the full path (including drive letter, folders, and file name) at 260 characters. This dates back to early MS-DOS and was carried into Windows for compatibility.

Other file systems have different limits:

  • NTFS (Windows): 255 characters per individual file name component, but the full path was traditionally limited to 260 characters via the Win32 API. With long path support enabled, NTFS can handle paths up to 32,767 characters.
  • FAT32 (USB drives, SD cards): 255 characters per file name, but the full path limit is also effectively 260 characters in Windows.
  • exFAT (modern USB drives): 255 characters per file name, path limit up to 32,767 characters.
  • ext4 (Linux): 255 bytes per file name component (not characters, so multi-byte UTF-8 names can be shorter), and the full path limit is 4,096 bytes.
  • APFS (macOS): 255 UTF-8 characters per file name, and the full path limit is 1,024 characters.

How File Name Limits Work

When you create a file, the file system stores the name in a directory entry. The limit applies to each component of the path (each folder name and the final file name) as well as the entire path. For example, on NTFS, you can have a folder named with 255 characters, but if you put that folder inside another folder, the combined path might exceed the limit.

In Windows, the 260-character limit is enforced by the Win32 API, not by NTFS itself. Many programs use the standard Windows file functions that impose this limit. However, some programs use the Unicode versions of these functions with a special prefix (\\?\) that allows paths up to 32,767 characters. Windows 10 and 11 have an option to enable long paths system-wide, which removes the 260-character limit for applications that are manifest-aware.

On Linux, the limit is per component (255 bytes) and the total path length is limited by the kernel to 4,096 bytes. This is usually enough for most uses, but deeply nested directories can hit this limit.

How to Fix the Error

The exact steps depend on your operating system and the file system in question. Here are the most common scenarios and solutions.

On Windows (NTFS, FAT32, exFAT)

  1. Shorten the file name or folder names – Right-click the file, select Rename, and use a shorter name. Also consider renaming parent folders to shorter names.
  2. Move the file closer to the root – For example, move it from C:\Users\YourName\Documents\Projects\2023\Reports\Final\ to C:\Reports\. This reduces the path length.
  3. Enable long paths in Windows – Open the Group Policy Editor (gpedit.msc) or the Registry Editor. Navigate to Computer Configuration > Administrative Templates > System > Filesystem and enable “Enable Win32 long paths”. Alternatively, set the registry key HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled to 1. After a reboot, many applications will support longer paths.
  4. Use the \\?\ prefix – If you are using a command prompt or a program that supports it, you can type \\?\C:\very\long\path\file.txt to bypass the limit. This works only in certain contexts.
  5. Use a file manager that supports long paths – Some third-party file managers (like Total Commander or 7-Zip) can handle long paths even when Windows Explorer cannot.

On Linux (ext4)

  1. Shorten the file name – Use the mv command to rename the file to something shorter.
  2. Reduce the depth of the directory tree – Move the file to a higher-level directory.
  3. Use a different file system – If you frequently need long paths, consider using a file system like XFS or Btrfs that has higher path limits (though they still have a 255-byte per-component limit).

On macOS (APFS)

  1. Rename the file or folders – Use Finder or the mv command in Terminal.
  2. Move the file to a location with a shorter path – For example, move it to your home directory.

Common Problems and Misconceptions

A common misconception is that the limit is only about the file name itself, but it actually includes the entire path. For example, a file named report_final_v2_2023_01_15.docx is fine, but if it’s inside a folder like C:\Users\John\Documents\Work\Projects\ClientName\Deliverables\Final\, the total path can easily exceed 260 characters.

Another issue is that even if you enable long paths in Windows, not all applications are compatible. Older programs and some modern ones that are not “long path aware” will still fail. You may need to use a workaround like mapping a network drive or using a symbolic link to shorten the path.

Also, when copying files to a USB drive formatted as FAT32, the 260-character limit applies even if your internal drive supports long paths. You may need to shorten the path before copying.

How to Check Path Length

To see if a path is too long, you can count the characters manually, but that’s error-prone. On Windows, you can use PowerShell:

Get-ChildItem -Path "C:\your\folder" -Recurse | Where-Object { $_.FullName.Length -gt 260 }

This lists all files with paths longer than 260 characters. On Linux, you can use find with a custom script, but the simplest is to try to access the file and see if it fails.

Alternatives to Shortening Names

If you cannot rename the file or move it, consider these alternatives:

  • Use a symbolic link – Create a symbolic link (symlink) with a short name that points to the long path. Then access the file through the symlink.
  • Map a network drive – On Windows, you can map a drive to a deep folder, giving it a short drive letter like Z:\, effectively shortening the path.
  • Use a file archiver – Zip the file with a short name, then store the archive. You can extract it later when needed.
  • Use a different file system – If you are on Linux, switch to a file system with a higher path limit like XFS (but note the per-component limit remains).

Frequently Asked Questions

Why does Windows still have a 260-character limit?

The limit is a legacy from the Win32 API’s MAX_PATH constant. Microsoft has kept it for compatibility with older software, but you can enable long paths in Windows 10 and 11 via Group Policy or the registry. Even then, some applications remain incompatible.

Does the limit include the file extension?

Yes, the file name includes the extension, and the full path includes all folder names and the file name with extension. The limit applies to the entire string.

Can I exceed the limit by using a network share?

Network paths can also hit the limit. If you map a network drive to a deep folder, the mapped drive letter replaces the entire UNC path, which can shorten it enough to work.

What is the maximum file name length on NTFS?

Each individual file name component (the file name itself, not including the path) can be up to 255 characters on NTFS. The full path can be up to 32,767 characters if long path support is enabled.

Why does my USB drive give a “file name too long” error even though the name is short?

If the USB drive is formatted as FAT32, the full path limit is 260 characters. Even if the file name is short, the folders leading to it might make the path too long. Shorten the folder names or move the file to the root of the drive.

Can I change the file system to remove the limit?

You can reformat a drive to a file system with higher limits, such as exFAT or NTFS on Windows, or ext4 on Linux. However, reformatting erases all data, so back up first. Also, the per-component limit of 255 characters remains on most file systems.