The Computer Oracle

How to delete directories with path/names too long for normal delete

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 2

--

Chapters
00:00 How To Delete Directories With Path/Names Too Long For Normal Delete
01:11 Accepted Answer Score 89
01:29 Answer 2 Score 499
01:48 Answer 3 Score 319
02:23 Answer 4 Score 34
02:58 Thank you

--

Full question
https://superuser.com/questions/78434/ho...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#windows #filemanagement

#avk47



ANSWER 1

Score 499


Use the 7-Zip File Manager to delete them.

If you are still having trouble, ensure that you utilize Shift+Delete inside the 7-Zip File Manager. Otherwise, Windows tries to move them to the Recycle Bin (which will fail again).




ANSWER 2

Score 319


None of the other (free) answers here worked for me, but I found one on another site:

rimraf <dir>

rimraf is a Node.js package, so you will need to install Node.js which includes npm. Then you can run:

npm install -g rimraf

Then you can run rimraf from the command line.

I found this solution because npm itself was causing this problem due to the way it nests dependencies.

By the way, rimraf gets its name from the UNIX command rm -rf, which recursively deletes files and folders.




ACCEPTED ANSWER

Score 89


I believe I've found a way to delete things from cmd. Originally I tried the del command, but that didn't work. Then I remembered rmdir. Doing the following:

rmdir /S /Q <dir>

seems to have worked.




ANSWER 4

Score 34


Without installing additional software you can use subst command to temporary create an alias to a long named directory.

e.g. If you want to delete folder C:\Very long directory\that exceed\length limit\blah blah blah\abcde\folder to be deleted you can use the command

subst x: "C:\Very long directory\that exceed\length limit\blah blah blah\abcde"

and then you can delete X:\folder to be deleted in Windows Explorer or in command prompt easily. To remove the temporary drive letter alias use the command

subst x: /d