js fs rename file code example
Example 1: fs renaming files
const fs = require("fs")
fs.rename("./testfile.txt", "./newtestfile.txt", (err) => {
if (err) console.log(err)
})
Example 2: rename file in js
var fs = require('fs');
fs.rename('sample_old.txt', 'sample_new.txt', function (err) {
if (err) throw err;
console.log('File Renamed.');
});