Last active
August 29, 2015 14:16
-
-
Save wangyangkobe/f1f3315ff45843ce0d95 to your computer and use it in GitHub Desktop.
extract *.tar.gz for SBG code.
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
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