Last active
April 25, 2016 11:35
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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