fs move code example
Example 1: node filesystem change directory of a file
const {promisify} = require('util');
const fs = require('fs');
const {join} = require('path');
const mv = promisify(fs.rename);
const moveThem = async () => {
const original = join(__dirname, 'bar/foo.js');
const target = join(__dirname, 'baz/qux.js');
await mv(original, target);
}
moveThem();
Example 2: node filesystem change directory of a file
var fs = require('fs-extra')
fs.move('/tmp/somefile', '/tmp/does/not/exist/yet/somefile', function (err) {
if (err) return console.error(err)
console.log("success!")
})