People need to see all the files in a folder and list it, but calm what I want is to enter the folder and read all the files and list, but if you find a folder between it and list what's in it too . This is by ordering the files by date.
Can anyone help me how? I really tried it in many ways ...
I did this, but I can not sort the files for the most recent dates.
function getReports(dir) {
fs.readdir(dir, function(error, files) {
for (var i = 0; i < files.length; ++i) {
var filePath = path.join(dir, files[i]);
if (fs.statSync(filePath).isDirectory()) {
getReports(filePath);
} else {
var result = files[i].split('.');
if(result[1].match(/html/))
{
$('.reports').append('<li><a href="#external" data-ext="file:///' + filePath + '">' + result[0] + '</a></li>');
}
}
}
});
}