Friday, November 18, 2016

How to Delete a Very Deep Directory Efficiently

In the daily routine of your job, you may have to deal with a directory that has levels very much, that is, the directory is very deep. This situation may often occur to those who use NPM which produces a node_modules directory that has a lot of levels.

Very Deep Directory Structure Image
Very Deep Directory Structure

This directory is the same as the other directories until you realize that actually, this directory requires special treatment to remove, especially on Windows operating systems. This directory cannot be removed immediately. You must remove the sub-directory at a certain level before you delete the directory. This is very inefficient and can slow down your performance.