Nodejs:How to grab all the files and archieve from subfolder

193 views Asked by At

I am working on node.js app, I have list of folders to be archived in %APPDATA%/Archive/****/Licensing, **** is different versions.(v195,v196,v197 etc)

From APPDATA I want to loop through all the version folders, and inside version folder I want to grab only the licensing folder for different version folders.

Here is what I tried

//I am not sure, how to loop over here 
var archiver = require('archiver'); 

var FileList = path.resolve(process.env.LOCALAPPDATA,'..\\Roaming\\Archive\\****\\licensing');
archive.directory(File, "FileList");

1

There are 1 answers

0
karansys On
var SAnsysDebugFile = path.resolve(process.env.LOCALAPPDATA,'..\\Roaming\\Archive');
glob(SAnsysDebugFile+'/v***/licensing','', function (err, files) {
    if (err) {
     console.log(err);
    } else {
        console.log(files);
        for (let i in files) {
            sUsagefile = files[i];
            archive.directory(files[i], "Archive");
        }
      }
})