0
People need to see all the files of a folder and list it, but calm down what I want is to enter the folder and read all the files and list, but if you find a folder enter it and list what is in it too. All this by ordering the files by date.
Can anyone help me how? I’ve really tried many ways...
I did that, but I can’t sort the files by 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>');
}
}
}
});
}