File System - File System Tree Traversal

Undraw File Manager Re Ms29

About

Because a file system arranges file in a tree structure (file system tree), when you want to read it, you perform a Tree - (Traversal|Search) which is therefore a recursion

Example

Pseudo code

function scanDirectory(directoryPath){
   for (childrenPath in directoryPath) {
        if (childrenPath is a directory) {
            print("A directory was found"+childrenPath);
            scanDirectory(childrenPath); // the recursion
        } else {
           print("A file was found"+childrenPath);
        }
}

scanDirectory("."); // Scan the current directory





Discover More
Node - File System

This article is file system function in Node The below code will rename all files if the suffix contains a number. Ex: from blue_oregon_x90.svg to blue_oregon.svg Steps: select only the files...



Share this page:
Follow us:
Task Runner