How to Fix "Filename Too Long or Target Path Too Long" Error
This error occurs when the path or filename length exceeds the allowable limit, often due to operating system restrictions on the total character count in a file path.
Why Does This Error Happen?
For example, Windows has a path length limit of 260 characters. This means the combined character count in the full path — including folder names and the filename itself — should not exceed this limit. When this limit is surpassed, you may encounter issues working with files, especially in complex folder structures or with lengthy file and folder names.
How to Resolve the Issue?
1. Shorten the File Path
An easy fix is to move the file or folder closer to the root directory (for example, from “C:\Users\UserName\Documents\…” to “C:\FolderName\…”), thereby reducing the path length.
2. Rename Folders and Files
Using shorter names for folders and files can help reduce the total path length, avoiding the 260-character limitation.
3. Use Command-Line Tools
If standard methods don’t solve the issue, you can try command-line tools. The robocopy
or xcopy
command can help move or copy files with long paths.
robocopy "C:\Long\Path\To\File" "C:\New\Shorter\Path" /E
4. Enable Long Paths in Windows 10 and Later
For Windows 10 users and newer, long path support can be enabled through Group Policy or the Registry:
- Open Group Policy Editor by typing
gpedit.msc
in the search bar. - Go to Computer Configuration > Administrative Templates > System > Filesystem.
- Find the Enable NTFS long paths setting and enable it.
To enable long paths via the registry:
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem /v LongPathsEnabled /t REG_DWORD /d 1 /f