How do I go through a folder and find out which is the newest created/modified file and put the full path of it into a var as string?
Haven't really figured out io/best practices for io
Take a look at http://nodejs.org/api/fs.html#fs_class_fs_stats
look at the ctime
or mtime
to find the created and modified time.
Something like this:
var fs = require('fs');
fs.readdir(".",function(err, list){
list.forEach(function(file){
console.log(file);
stats = fs.statSync(file);
console.log(stats.mtime);
console.log(stats.ctime);
})
})
loops the current directory (.) and logs the file name, grabs the file stats and logs the modified time (mtime) and create time (ctime)