I am a certified trainer that likes to share my knowledge with the world.
Also, I am an adopter of continuous learning and evolving idea.
https://dev.to/wolfiton/who-am-i-3lj7
Searching my repositories, I found an example where I used node for automation. I think it can serve as a seed for you.
It uses 7zip to create a separated file for each sub-directory.
Useful for when you have one directory with logs for each day or month and want a single zip file per day.
It launches a process for each core of you processor as needed.
You need 7zip installed in your computer. (in linux, sudo apt install p7zip-full)
Save it as zipsubs, mark it as executable chmod +x zipsubs
zipsubs . .git node_modules will zip all subdirs of current dir ignoring .git and node_modules.
It has no dependencies.
#!/usr/bin/env node
const{exec}=require('child_process'),fs=require('fs'),path=require('path'),rootDir=process.argv[2],ignore=process.argv.slice(3),cpuCount=require('os').cpus().length/2// no hiper threadingif(!rootDir){console.log('zipsubs: 7zip all subdirs of a directory.\n example of use: zipsubs . [ignore list] ')process.exit()}letdirs=subDirs(path.resolve(rootDir)).filter(d=>ignore.indexOf(d)==-1),running=0zipNext()functionzipNext(){// launch a process for each core, as neededletdir=dirs.shift()if(dir){running++zipDir(dir,()=>{running--;zipNext()})if(running<cpuCount)zipNext()}}functionzipDir(dir,callback){letcmd=`7z a ./${dir}.7z ${path.join(rootDir,dir)}/* -r`console.log(cmd)exec(cmd,callback)}functionsubDirs(dir){letres=[]fs.readdirSync(dir).forEach(f=>{if(fs.statSync(path.join(dir,f)).isDirectory())res.push(f)})returnres}
I am a certified trainer that likes to share my knowledge with the world.
Also, I am an adopter of continuous learning and evolving idea.
https://dev.to/wolfiton/who-am-i-3lj7
It seems that I will have to take into consideration node for my list of scripting languages.
Thanks @bittnkr @avalander @tobiassn
Searching my repositories, I found an example where I used node for automation. I think it can serve as a seed for you.
It uses 7zip to create a separated file for each sub-directory.
Useful for when you have one directory with logs for each day or month and want a single zip file per day.
It launches a process for each core of you processor as needed.
You need 7zip installed in your computer. (in linux,
sudo apt install p7zip-full
)Save it as zipsubs, mark it as executable
chmod +x zipsubs
zipsubs . .git node_modules
will zip all subdirs of current dir ignoring.git
andnode_modules
.It has no dependencies.
Thanks for sharing and explaining where you use it, really appreciate it.