Write a filename in samefile.

20 views
Skip to first unread message

Arun Wadikar

unread,
Mar 30, 2017, 4:03:13 PM3/30/17
to nodejs

i wants to save the fiilename in samefile and the format is like that

Filename:02_27_2017_...@gmail.com_9_45_45_PM.wav

want the above filename in same file as

02_27_2017

wadik...@gmail.com

9_45_45

like this


Please i want to write the filename in samefile i did that one like below but its actually removing the already existed data in the same file and writing the same file name itself.

const testFolder = './tests/';
const fs = require('fs');
fs.readdir(testFolder, (err, files) => {

files.forEach(file => {

console.log(file.substring(0,file.length-4));

fs.writeFile('./tests/'+file, file.substring(-4), function(err) {

if(err)
{
return console.log(err);
}

});
})
})

so i want to keep the alrady existed data how i can please let me know...thanks

Reply all
Reply to author
Forward
0 new messages