Skip to content
tricknfixGAMING · TECHNOLOGIE · INFORMATIQUE
Create

Translation of the initial post. Replies remain in their original language. Read the original

#windows-11·Open questionTutorial

File name or path too long on Windows 11: cause and solutions

Tutorial

Windows 11 refuses to copy, move, extract or delete a file, saying that its name or path is too long? The problem almost always comes from an old Windows limit: 260 characters for the full path of a file, folders included. This guide explains how to recognise it and work around it, from the simplest solution (shortening the path) to the tools built into Windows (subst and robocopy), then how to turn on long path support and what its limits are. The steps also apply to Windows 10.

Problem

  • A message says that the file name or destination path is too long.
  • Copying or moving a folder stops on some files only, often the most "deeply nested" ones.
  • Extracting a ZIP archive fails even though the archive is not damaged.
  • A folder containing many nested subfolders refuses to be deleted.
  • A program (development tool, backup, sync) reports a path too long error.

Where the 260-character limit comes from

Microsoft documents that, in the Windows programming interface (Win32 API), the maximum length of a path is set by the MAX_PATH value, i.e. 260 characters. This total includes the drive letter, the colon, each backslash, the name of each folder, the file name and an invisible terminating character. On drive D, that leaves about 256 usable characters after D:\.

The limit applies to the full path, not to the file name alone. A file with a short name can therefore exceed it if it sits at the bottom of a long series of folders. Microsoft gives the example of a Git repository with long file names cloned into a folder that itself has a long name. Each element of the path (a folder or file name) is also limited, most commonly, to 255 characters.

Observe before acting

What you seeLikely causeStep
The error appears when copying or extracting to an already deep folder (Desktop, Documents, OneDrive, cascading subfolders)The destination folder adds too many charactersStep 1
You need to open, rename or delete a file located deep in a folder treeThe existing path already exceeds the limitStep 2
You need to copy or move a whole large folder treeFile Explorer stumbles on the deepest filesStep 3
A nested folder refuses to be deleted, even after shorteningFolder tree too deepStep 4
A specific program reports a path too longLong path support turned off in WindowsStep 5

If the message says a file is too large for a USB stick, rather than a path being too long, it is a different problem: see Fichier de plus de 4 Go impossible à copier sur une clé USB : FAT32 et solutions.

Step 1: shorten the path

When to use it: in most cases, especially when copying or extracting an archive.

Suggested solution

  1. Create a folder with a very short name at the root of a drive, for example C:\T or D:\T.
  2. Copy or extract the archive into this folder rather than into a deep folder such as the Desktop or a subfolder of Documents.
  3. If the error concerns existing files, give one or two parent folders in the tree shorter names (for example "Holiday photos backup 2024" becomes "Hol24").
  4. Run the copy, move or extraction again.

Expected result: the operation completes without error, because each file now has a shorter full path.

Shortening a parent folder shortens the path of every file it contains in one go. It is often faster than renaming files one by one.

Step 2: reach a deep folder through a drive letter (subst)

When to use it: you cannot rename the parent folders, but you need to reach files located deep in the folder tree.

The subst command, built into Windows, associates a virtual drive letter with a folder. The path seen by programs then becomes much shorter.

Suggested solution

  1. Open Command Prompt normally, without "Run as administrator".
  2. Associate a free letter (here Z) with the deepest folder you can reach, replacing the path with yours:
Batch3 lines

subst Z: "D:\Dossier\Sous-dossier\Encore un sous-dossier"
  1. Open drive Z: in File Explorer and work on the files from this drive: rename, move or delete what you need.
  2. When you have finished, remove the virtual drive:
Batch3 lines

subst Z: /d

Expected result: the files can be reached from Z: with a much shorter path, and the operations succeed.

Removing the virtual drive does not delete any file: only the drive letter shortcut disappears. Microsoft states that some commands, including chkdsk and format, must not be used on a drive created with subst.

Step 3: copy or move a folder tree with robocopy

When to use it: you need to copy or move a whole folder containing paths that are too long, and File Explorer stops partway.

The robocopy tool, included with Windows, supports paths longer than 256 characters by default: its documentation even provides a /256 option to turn this support off.

Suggested solution

  1. Open Terminal or Command Prompt.
  2. First do a dry run with the /l option, which lists the files without copying anything:
Batch3 lines

robocopy "D:\Source" "E:\Destination" /e /l
  1. If the list matches what you want to copy, run the command again without /l:
Batch3 lines

robocopy "D:\Source" "E:\Destination" /e
  1. For a move (files are deleted from the source once copied), use /move instead of /e, after checking the dry run result:
Batch3 lines

robocopy "D:\Source" "E:\Destination" /move

Expected result: robocopy copies the whole folder tree, including files whose paths are too long for File Explorer, then shows a summary of copied, skipped and failed files.

The /e option copies subfolders, including empty ones. Check the order of the two paths carefully: the first is the source, the second the destination.

Step 4: delete a nested folder that is too deep

When to use it: a folder refuses to be deleted because of paths that are too long, and steps 1 and 2 were not enough.

This method uses robocopy with the /mir option, which makes one folder identical to another, deleting from the destination everything that does not exist in the source. By choosing an empty folder as the source, the destination is emptied. A mistake in the destination path deletes the wrong files: copy the command carefully.

Suggested solution

  1. Check that the folder to delete no longer contains anything you want to keep.
  2. Create an empty folder, for example C:\Vide.
  3. First do a dry run with /l, which shows what would be deleted without touching anything:
Batch3 lines

robocopy "C:\Vide" "D:\Dossier a supprimer" /mir /l
  1. If the list only contains items from the folder to delete, run the real command:
Batch3 lines

robocopy "C:\Vide" "D:\Dossier a supprimer" /mir
  1. The folder is now empty. Delete it, along with the empty folder created in step 2:
Batch4 lines

rd "D:\Dossier a supprimer"
rd "C:\Vide"

Expected result: the folder's content is deleted, then the folder itself. Files deleted this way do not go through the Recycle Bin.

Step 5: turn on long path support

When to use it: a specific program reports a path too long, and its publisher states that it supports Windows long paths.

Since Windows 10 version 1607, Microsoft has removed the MAX_PATH limit from many file functions, but only for applications that declare it (longPathAware element in their manifest) and only if a system setting is turned on. Microsoft insists that this setting only affects applications that have been modified to take advantage of it, not all applications. So it does not make the error disappear in every program.

Suggested solution

Windows 11 version 25H2 and later:

  1. Open Settings > System > Advanced.
  2. Turn on Enable long paths (in earlier versions, this page was called For developers).

Other versions, with PowerShell:

  1. Open Terminal as administrator.
  2. Type the command published by Microsoft:
PowerShell3 lines

New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

In both cases:

  1. Restart the PC. Microsoft explains that each program reads this setting when it starts, and that a restart may be needed for all programs to take it into account.
  2. Run the operation again in the program concerned.

Expected result: compatible programs accept paths longer than 260 characters. For the others, go back to steps 1 to 4.

On Pro and Enterprise editions, the same setting exists as a Group Policy: Computer Configuration > Administrative Templates > System > Filesystem > Enable Win32 long paths (in a French-language Group Policy Editor, the labels are translated).

Special cases and rolling back

SituationWhat you need to know
Going back to the original settingTurn off Enable long paths in Settings, or run the step 5 command again with the value 0 instead of 1, then restart.
The option is greyed out or switches back on its ownOn a PC managed by a company or school, a policy may enforce this setting. Contact the administrator.
You deleted the wrong content with robocopy /mirThe files are not in the Recycle Bin. Restore them from your backup or File History, if you have one.
You cannot change the folder because of an "Access denied" messageThis is not a path length problem but a permissions problem.
The Recycle Bin refuses to emptySee Corbeille qui ne se vide pas sous Windows 11 : solutions (French guide).

To avoid this problem in the future

  • Keep folder names short for deep folder trees (backups, projects, downloaded archives).
  • Extract archives into a folder close to the root of the drive, then move only what you need.

Final check

  • ☐ You have identified the operation that fails (copy, extraction, deletion or a specific program).
  • ☐ The path has been shortened, or the work was done from a subst drive.
  • ☐ The subst virtual drive was removed with /d once the work was done.
  • ☐ robocopy copies were checked with a dry run (/l) before the real command.
  • ☐ If you turned on long paths, the PC was restarted.

Sources

Still having the problem?

Reply in this topic with your Windows version (Settings > System > About), the operation that fails, the exact text of the error message, the program used and the approximate number of characters in the path. Replace your user name and personal folder names with generic names before posting.

Have an idea or a suggestion?

Be the first to join the discussion.

Reply

Reply without signing up using a TNF_… username saved on this device. You can post once every 30 minutes until you verify your email.

Add a GIF

Up to 5 GIFs per message.

Your draft stays on this device while you write.