var fs = require("fs");
const {join} = require("path");
function findFilesPath(startPath) {
let result = [];
function finder(path) {
let pathArray = fs.readdirSync(path);
pathArray.forEach((val, index) => {
let fPath = join(path, val);
let stats = fs.statSync(fPath);
if (stats.isDirectory()) finder(fPath);
if (stats.isFile()) {
fs.utimes(fPath, new Date(), (new Date('2021-09-14 17:04')), function (err) {
if (err) {
console.log("修改时间失败")
throw err;
}
})
result.push(fPath);
}
});
}
finder(startPath);
console.log(result);
return false;
}
findFilesPath('F:/my-project/myNode/demo');
最后推广一波服务器
【腾讯云】爆款1核2G云服务器首年48元,还有iPad Pro、Bose耳机、京东卡等你来抽!