Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js get files

/*--------------------------------------------------------------------------------------
|  _______    _    _____ _             _ _           ________     ___   ___ ___  __     |
| |__   __|  (_)  / ____| |           | (_)         /  ____     |__  / _ \__ /_ |    |
|    | | __ _ _  | (___ | |_ _   _  __| |_  ___    /  / ___|       ) | | | | ) || |    |
|    | |/ _` | |  \___ | __| | | |/ _` | |/ _   |  | |       |   / /| | | |/ / | |    |
|    | | (_| | |  ____) | |_| |_| | (_| | | (_) | |  | |___    |  / /_| |_| / /_ | |    |
|    |_|\__,_|_| |_____/ \__|\__,_|\__,_|_|\___/     \____|  /  |____|\___/____||_|    |
|                                                   \________/                          |
--------------------------------------------------------------------------------------*/

const fs = require('fs');

function getFiles(dir, files_){
    files_ = files_ || [];
    var files = fs.readdirSync(dir);
    for (var i in files){
        var name = dir + '/' + files[i];
        if (fs.statSync(name).isDirectory()){
            console.log(`INFO: ${name}`)
            getFiles(name, files_);
        }
        else{
            files_.push(name);
        }
    }
    return files_;
}
getFiles(testFolder);
 
PREVIOUS NEXT
Tagged: #js #files
ADD COMMENT
Topic
Name
7+4 =