Wednesday, 15 March 2017

How to get files from multiple directories using fs or async methods?

I am trying to write logic where i can get files information from each directory , How can i achieve that using async or any fs method. I am passing fileInfo and filePath to function compareDates for further implementation.

controller.js

var directories = ['./logs/dit', './logs/st','./logs/uat']
            async.eachSeries(files, function(file, callback) {
                var filePath = path.join(ditDir, file);
                var fileInfo = {};
                fs.stat(filePath, function(err, stats) {
                    if (err) {
                        console.info("File doesn't");
                    } else {
                        fileInfo.fileDate = stats.birthtime;
                        fileInfo.filename = file;
                        compareDates(fileInfo, filePath);
                    }
                });
            });



via hussain

No comments:

Post a Comment