Created
February 3, 2020 16:53
-
-
Save steve-ross/a70e8a748c7ed6a8c426b9f7760580a9 to your computer and use it in GitHub Desktop.
read dir node script invoke: node readdir PATHTODIR
This file contains 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
const path = require('path'); | |
const fs = require('fs'); | |
//joining path of directory | |
const directoryPath = path.join(process.argv[2]); | |
//passsing directoryPath and callback function | |
fs.readdir(directoryPath, function (err, files) { | |
//handling error | |
if (err) { | |
return console.log('Unable to scan directory: ' + err); | |
} | |
//listing all files using forEach | |
const arrayOfFiles = []; | |
const s3Path = 'https://gftc2020.s3.amazonaws.com/galleries/monday-03-20/'; | |
files.forEach(function (file) { | |
// Do whatever you want to do with the file | |
arrayOfFiles.push(s3Path + file); | |
console.log('"' + s3Path + file + '"' + ','); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment