alhoww
Last Updated: November 20, 2017
·
30.27K
· icflorescu
Icflorescu

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

Say Thanks
Respond

14 Responses
Add your response

23674
Icflorescu

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 ·
27445

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

over 1 year ago ·
27752

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 ·
28052

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

over 1 year ago ·
28055

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 ·
28129

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 ·
28246

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

over 1 year ago ·
28249
Icflorescu

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

over 1 year ago ·
28251

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 ·
28419

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

11 months ago ·
28586

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.

10 months ago ·
28932

FastCopy is open source C project written by SHIROUZU Hiroaki and is "The Fastest Copy/Delete Software on Windows." It supports UNICODE and filename and path that are normally too long. How to use - https://goo.gl/5fjO1z

7 months ago ·
28953

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

7 months ago ·
29449

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

about 2 hours ago ·
Awesome Job

B6c77ad0 c95b 11e7 8263 8f89080b8db6
Ruby Developer Backend
·
Austria (Vienna or Linz)
·
Full Time