Skip to content

Instantly share code, notes, and snippets.

@evdokimovm
Last active April 25, 2016 11:35
Show Gist options
  • Save evdokimovm/3d9be88f49bc9b833507b4e88cfabd52 to your computer and use it in GitHub Desktop.
Save evdokimovm/3d9be88f49bc9b833507b4e88cfabd52 to your computer and use it in GitHub Desktop.
Copy files from multiple directories into one directory with Node.js, graceful-fs https://www.npmjs.com/package/graceful-fs and graceful-ncp package https://www.npmjs.com/package/graceful-ncp
var fs = require('graceful-fs');
var ncp = require('graceful-ncp').ncp;
// var FileQueue = require('filequeue');
// var fq = new FileQueue(100);
ncp.limit = 16;
fs.readdir(__dirname, function(err, files) {
for (var i = 0; i < files.length; i++) {
ncp(files[i], 'C:/path/to/output/folder', function(err) {
if (err) {
return console.error(err);
}
console.log('done!');
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment