Having issues deleting a folder or a file? Are you getting messages about filename too long or path too long? Then read on for a simple solution.

Windows uses a naming convention called “Long Filenames (LFN)”. The LFN system supports file names up to 255 characters. Windows also has a flag called MAX_PATH which has value 260, meaning a file path can have a maximum of 260 characters including the drive. So, when files are created by other programs that have more than 260 characters they cannot be deleted using Windows or DOS commands. You’ll get the message file name too long or path too long.

Destination Path Too Long

Method 1: Using 7zip

7-Zip is open source file archiver with a high compression ratio.

  1. Find the path of the file with the filename that is too long to delete
  2. Navigate to the file, as if you’re going to create an archive within the 7-zip or winrar application, right click on the file (or F2) and choose to rename. Give the file a shorter name.
  3. Success! the file now has a shorter name and can be deleted.

Method 2: Using Robocopy

Robocopy is default available on Windows 7 and higher. Robocopy is a Windows command to copy files from one location to another.

The syntax for Robocopy is quite easy:
robocopy <Source> <Destination> [<File>[ …]] [<Options>]

There is an option called PURGE. The PURGE option deletes destination files and directories that no longer exist in the source. We will use this flag to delete the folders recursively.

  1. create an empty directory (C:\emptyfolder). Let’s say the folder we want to delete is C:\deletefolder
  2. Run robocopy c:\emptyfolder c:\deletefolder /purge. 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:\deletefolder) recursively!

Source Path too Long

Method 3 (For NodeJS users): Using RimRaf

Working with Node.js on Windows platform, can be tricky and it might happen that some trivial action will fail, for instance removing nodemodules folder. This is due to recursive references of folders and files within nodemodules, which ultimately ends up with a long name (path).

  1. Install RimRaf npm install rimraf -g
  2. Delete the folder using rimraf nodemodules
NordVPN - Discount

Last updated:


15 Comments

Ross Gram · May 10, 2018 at 9:17 pm

I would like to suggest you, try LongPathTool to resolve this issue. This tool is very helpful to resolve the issue.

Richard Brock · July 1, 2018 at 5:09 am

Solve this using Long path tools

kevin prack · July 1, 2018 at 5:12 am

The fastest and best way is to use long path tools

David Galler · July 19, 2018 at 8:27 pm

Have you tried ‘long path tool’
it’ very useful in this type of case.

Brandon Wooten · August 5, 2018 at 9:55 pm

use long path tool

Steven Crag · July 4, 2019 at 12:31 am

I highly recommend Long Path Tool it automatically deletes the folder you selected, including all its files and subfolders, regardless of their path length (even if they are in a network folder).

Ana Gray · July 25, 2019 at 9:50 pm

I had this annoying problem too and used Long Path Tool and it is so easy to use and very helpful

Fred Sheely · September 7, 2019 at 3:31 pm

Loong path tool was always there for me in this type of problem. I’ve been using it for months now and it is really helpful

Peter Smith · November 21, 2019 at 9:34 pm

I would like to suggest you, try LongPathTool program to resolve this issue. This tool is very helpful to resolve the issue.

Mark Lee · November 24, 2019 at 2:52 pm

“You can use the long_path_tool for this issue.

In using the long path tool you just have to click on the long_path_tool application icon and the tool will provide you a window that contains all your files. You have now the capability to move, delete rename and modify your files without getting error messages. It is a user friendly tool and it is a quick fix for this issue.”

Ethan Jacko · January 8, 2020 at 10:57 pm

I personally recommend long path tool

Mark Bryant · March 31, 2020 at 9:18 pm

I suggest you try Long path tool is the very good

program for easily delete, copy & rename long path

files, error, unlock solution.
Try it and solve your problem.

Damien Brock · May 8, 2020 at 3:42 pm

You can use Longpath Tool. It worked for me like a charm.

Juan_Miller · June 3, 2020 at 10:16 am

Try to use Long Path Tool, it really can help you with that.
It will really help you to solve your problem.

Mark Track · July 1, 2020 at 12:34 pm

Long Path Tool is solve the issue very easily and very use full.

Leave a Reply