Last Updated: December 13, 2021
·
42.4K
· Ionut-Cristian Florescu

Solving the "source path too long" NTFS issue

TL;DR

Source path too long error in Windows

If you're trying to delete a folder or file and Windows keeps barking at you "Source path too long", use rimraf command line utility instead.

The problem

Sometimes you end up having large folder trees on your hard drive that NTFS simply can't delete. Web / Node.js developers happening to work on Windows are probably aware of this issue (why would a Web / Node.js developer be working on Windows is a good question and the subject of another story).

This may look like a minor issue, but really can be a show-stopper if you're trying to use Node.js apps on Windows.

Leaving aside the technical mystery of how is the OS able to create those files but cannot delete them, here's how sane people would try to solve this problem:

File Explorer - Delete

Trying File Explorer - Delete

Nope. Can't do it.

File Explorer - Shift+Delete

I know. If it's too long for Recycle Bin, I'll just use Shift+Delete.

Trying File Explorer - Shift+Delete - Step 1

Trying File Explorer - Shift+Delete - Step 2

No, it doesn't work. Hmmm...

Command prompt

I'm a technically-literate person, so I'll use rmdir in Command Prompt.

Trying the Command prompt - step 1

Trying the Command prompt - step 2

WTF?!...

The insane way: access the drive from a different OS

People happening to dual-boot their computers will be able to remove the stubborn file / folder by mounting the drive in Linux. It's impractical, though, even for geeks.

What you should do

Node.js developers may be familiar with a cool little useful NPM called rimraf. Although rimraf is mostly used in Node.js application scripts, it does have a command-line utility. Which means you can install it globally like this (assuming you already have Node.js installed):

npm i -g rimraf

Then you can simply use rimraf instead of rmdir, like this:

Rimraf

23 Responses
Add your response

Well, I see no point in using Long Path Tool or any other paid app when my workflow already includes Node.js and there's a free and faster command-line alternative in the ecosystem.

over 1 year ago ·

just try duplicate files deleter, it is a great solution of that issue....

over 1 year ago ·

Long Path Tool help me a lot when i have an issue like file deleting or renaming the file. Also good to use if file name and file extension is too long

over 1 year ago ·

“Long Path Tool” is very helpful for this error !
You can use to solve this problem

over 1 year ago ·

Long Path Tool help me a lot when i have an issue like file deleting or renaming the file. Also good to use if file name and file extension is too long.

over 1 year ago ·

This is the right solution to this issue by far! I never thought to find the answer in a web developer site. Thank you very much, you guys made my day.

over 1 year ago ·

“Long Path Tool” is very helpful for this error !
best solution for your problem.

over 1 year ago ·

So much shameless advertising about that "long path tool" or whatever it's called...

over 1 year ago ·

Thank you,
Long path tool is the very good program for error, unlock solution.
Try it and solve your problem.
I used long path tool and I solve my error, unlock problem solution.

over 1 year ago ·

Hello everyone,
I suggest everyone a software which can solve this problem. The name of the software is Long Path Tool.
thanks
snizhana

over 1 year ago ·

Hey I suggest that you try Long Path Tool.

It´s a great tool to to fix the message that say "The specified file or folder name is too long. The URL path for all files and folders must be 260 character..."

I used it and had a good and fast solution to my problem.

Highly recommendable.

over 1 year ago ·

I would also recommend using Long Path Tool. It's the best help you can get

over 1 year ago ·

I would also recommend the long path tool . Some says it don't work but it really work perfectly fine for me. :)

over 1 year ago ·

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

over 1 year ago ·

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

over 1 year ago ·

Have you tried long path tool?
it's very useful in this type of case.

over 1 year ago ·

use long path tool....it's very helpful for me.

over 1 year ago ·

I suggest you try Long path tool is the very good program for error, unlock solution.
Try it and solve your problem.
I used long path tool and I solve my error, unlock problem solution.

over 1 year ago ·

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

over 1 year ago ·

I suggest you Long Path Tool will let you easily delete, copy or rename long path files, you can try it for better service.

over 1 year ago ·

Long Path Tool help me a lot when i have an issue like file deleting or renaming the file. Also good to use if file name and file extension is too long

over 1 year ago ·

i try longpath tool software to solve long path file that can not open. so you can try this . Good Luck

over 1 year ago ·

Many tools can handle this issue like Gs Richcopy 360, Long Path Fixer ...etc, but I find your way can be applied, my question is how can your way work for example over 100 paths at once?

over 1 year ago ·