Sunday, 2 April 2017

Wants to write filename in same file suppose filename 02_02_2017_wadikararun@gmail.com_4_45_AM.wav

Through this code i can able to write the filename in same file but thing is unable to save already existed data in the same file.

const testFolder = './2_27_2017/';
const fs = require('fs');
fs.readdir(testFolder, (err, files) => {
  files.forEach(file => {
    console.log(file.substring(0,file.length-4));
    fs.writeFile('./2_27_2017/'+file, file.substring(-4), function(err) {
    if(err) {
        return console.log(err);
    }

}); 
})
})



via Arun Wadikar

No comments:

Post a Comment