/** * Created by Administrator on 2016/1/16. */ var fs = require(‘fs‘); var filedir=‘automay‘; console.log(filedir); fs.watch(filedir, function(ev, file){ //只要一个文件变化,对文件夹下所有文件进行读取,然后合并 console.log(ev + ‘ / ‘ + file); fs.readdir(filedir, function(err, dataList){ var arr = []; console.log(dataList); dataList.forEach(function (f){ if(f){ var info = fs.statSync(filedir + ‘/‘ + f); console.log(info); if(info.mode == 33206){ console.log(info); arr.push(filedir + ‘/‘ + f); } } }); var content = ""; arr.forEach(function (f){ var c = fs.readFileSync( f ); content += c.toString() + ‘\n‘; }); fs.writeFile("autoMerge.html",content); }); })
时间: 2024-10-12 11:55:58