1var fs = require('fs');
2
3fs.rename('sample_old.txt', 'sample_new.txt', function (err) {
4 if (err) throw err;
5 console.log('File Renamed.');
6});
1
2 var fs = require('fs');
3
4fs.rename('mynewfile1.txt', 'myrenamedfile.txt', function (err) {
5
6 if (err) throw err;
7 console.log('File Renamed!');
8});