Deleting directories/files with paths too long for Windows delete

Windows Source Path Too Long

In Windows API the maximum length for a path is defined by MAX_PATH  which is 260 characters. A local path is structured using drive letter, colon, backslash and folder names separated by backslashes, followed by a null terminator.

Windows has Unicode versions of file functions to provide an extended path length up to 32767 characters. The components used to create this path (separated by backslashes) can each have a value specified by the lpMaximumComponentLength  parameter. This value is commonly 255 characters. To specify an extended length path, the \\?\  prefix is used, like this:

You can not use the \\?\  prefix with a relative path, relative paths are always limited to a total of MAX_PATH  characters.

Note, in Windows 10 version 1607 onward, the MAX_PATH  limitations have been removed.

Many Windows applications expect the maximum path length to be less than 255 characters. When you try to copy or delete files you will see an error like “The file name(s) would be too long for the destination folder. You can shorten the file name and try again, or try a location that has a shorter path.” This problem often arises with website cache files.

There are several solutions to this problem.


Download and install 7-Zip . Use the 7-Zip the Manager to delete the folders. You must use SHIFT  + DEL  inside 7-Zip’s File Manager, otherwise Windows will try to delete the files.

7Zip File Manager
7Zip File Manager

Mapped Path

If the folder you want to delete is shared on another computer or server use a mapped drive half way down the path. You are shortening the overall character count for the files contained in the folder by substituting the folder (with a long file path) with a drive letter. You can copy or delete the files without violating the limit. When you’ve finished delete the mapped folder.

Rename Folders

Work your way into the path, renaming each successive parent folder to “a” and attempting to delete. You are shortening the path each time. You can normally delete after 4 or 5 iterations.

Use a Linux Live CD!

Boot from an Linux Live CD and delete.


Use robocopy  (pre-installed with Windows since Vista). For example, if you need to delete everything in C:\FilePathTooLongFolderNameBlahBlah create a new folder call C:\EmptyFolder (leave it empty), then open a command prompt and run:

Since there are no files or folders in the source directory (C:\EmptyFolder), it simply deletes the files and folders under the target directory (C:\FilePathTooLongFolderNameBlahBlah) recursively.

Delete the empty folder C:\EmptyFolder when finished.

You May Also Like

About the Author: George