Skip to content

Instantly share code, notes, and snippets.

@wangyangkobe
Last active August 29, 2015 14:16
Show Gist options
  • Save wangyangkobe/f1f3315ff45843ce0d95 to your computer and use it in GitHub Desktop.
Save wangyangkobe/f1f3315ff45843ce0d95 to your computer and use it in GitHub Desktop.
extract *.tar.gz for SBG code.
var path = require('path');
var fs = require('fs');
var tarball = require('tarball-extract');
var rimraf = require("rimraf");
var srcDir = "C:\\Users\\elqstux\\Desktop"
var dstDir = "C:\\Users\\elqstux\\Desktop\\SBG Code\\src";
var files = ["SOM_CRA1190221.tar.gz", "SYF_CRA1190070.tar.gz", "auto.tar.gz", "SGC_CRA1190962.tar.gz"];
files.map(function(file){
rimraf(path.join(dstDir, file.split('.')[0]),
function(err){
if(err)
console.log(err);
else
{
tarball.extractTarball(path.join(srcDir, file), dstDir, function(err){
if(err)
console.log(err)
else
{
fs.unlink(path.join(srcDir, file), function(err){
console.log("finished: ", file);
});
}
})
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment