You might want to check out ncp . He does exactly what you are trying to do; Recursively copy files from a path to another.
Here's something to start with:
const fs = require("fs");
const path = require("path");
const ncp = require("ncp").ncp;
ncp.limit = 0;
var thePath = "./";
var folder = "testFolder";
var newFolder = "newTestFolder";
ncp(path.join(thePath, folder), path.join(thePath, newFolder), function (err) {
if (err) {
return console.error(err);
}
console.log("Done !");
});
source
share