From 9974158ac7cc66535f32900b7385ff95231fbf9e Mon Sep 17 00:00:00 2001 From: hemanth-hk Date: Tue, 31 Mar 2020 16:17:01 +0530 Subject: [PATCH] Added mv command --- commands/mv.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 commands/mv.js diff --git a/commands/mv.js b/commands/mv.js new file mode 100644 index 0000000..4b90bba --- /dev/null +++ b/commands/mv.js @@ -0,0 +1,22 @@ +//importing filesystem +const fs = require('fs'); + +//function movinf the file +function mv(old_path, new_path) { + source = './' + var old_path_wrt = source.concat(old_path); + var new_path_wrt = source.concat(new_path); + + fs.rename(old_path_wrt, new_path_wrt, (err) => { + if (err) { + console.log("Invalid path"); + } else { + console.log("File moved"); + } + }); + + +} + +//exporting the mv function +module.exports = mv; \ No newline at end of file