node.js - Applying limit in listing large numbers of files in nodejs -
i have folder millions of images stored in it. want 10 random jpg images folder.
i trying below code list images , gives big list of images after time (5-6 minutes) can apply if condition determine jpg , can 10 random records list.
fs.readdir(imagefolder, function (err, files) { console.log(files.length); });
is there quick way list few images of required extension?
i got solution,
var sys = require('sys') var exec = require('child_process').exec; var child; child = exec('find '+imagefolder+' -name "*.jpg" | shuf -n 10', function (error, output, stderr) { console.log(output); });
Comments
Post a Comment