You can use node file system commands. For example, you can use fs.readdir to get all file names in a folder:
//First you have to require fs
const fs = require('fs');
//You can read a directory like this
fs.readdir(`./your/dir/absolute/path`, (err, files) => {
//This function will return all file names if existed
});
You can use fs.readFile to read a file:
//First you have to require fs
const fs = require('fs');
//You can read a directory like this
fs.readdir(`./your/dir/absolute/path`, (err, files) => {
//If there is file names use fs.readFile for each file name
if(!err, files){
files.forEach(fileName => {
fs.readFile('./your/dir/absolute/path/' + fileNmae, 'utf8', (err,data){
//You will get file data
})
})
}
});
You can create a file with the same data in a another folder using fs.open and fs.writeFile:
const fs = require('fs');
//You can read a directory like this
fs.readdir(`./your/dir/absolute/path`, (err, files) => {
//If there is file names use fs.readFile for each file name
if(!err, files){
files.forEach(fileName => {
fs.readFile('./your/dir/absolute/path/' + fileNmae, 'utf8', (err,data){
//Use fs.open to copy data to a new file in a new dir
fs.open('./new/folder/absolute/path' + newFileName, 'wx', (err, fd) => {
//If file created you will get a file file descriptor
if(!err && fd){
//Turn data to sting if needed
var strData = JSON.stringify(data)
//Use fs.writeFile
fs.writeFile(fd, strData, (err) => {
//Close the file
fs.close(fd, (err) => {
//if no err callback false
})
})
}
})
})
})
}
});