Created
June 8, 2020 18:39
-
-
Save ngokevin/19f002a64ae0026539bbd0085fb0c962 to your computer and use it in GitHub Desktop.
Hakuneko Manga Combiner
This file contains hidden or 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
const glob = require('glob'); | |
const fs = require('fs-extra'); | |
const path = require('path'); | |
const rimraf = require('rimraf'); | |
const zipdir = require('zip-dir'); | |
const comicPath = process.argv[2]; | |
const comicName = comicPath.split('/').slice(-1)[0].replace(/ /g, ''); | |
const zipPath = `${comicName}Zip`; | |
rimraf.sync(zipPath); | |
fs.mkdirSync(zipPath); | |
glob.sync(`${comicPath}/*`).forEach(chapterPath => { | |
const chapterNumber = chapterPath.split('/').slice(-1); | |
glob.sync(path.join(chapterPath, '*.jpg')).forEach(file => { | |
const newFile = path.join(zipPath, `${chapterNumber}-${path.basename(file)}`); | |
fs.copySync(file, newFile); | |
console.log(newFile); | |
}); | |
}); | |
zipdir(zipPath, {saveTo: `${comicName}.cbz`}, () => { | |
console.log(`Done! (${comicName}.cbz)`); | |
rimraf.sync(zipPath); | |
}); |
This file contains hidden or 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
{ | |
"name": "mangazipper", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"dependencies": { | |
"fs-extra": "^8.1.0", | |
"glob": "^7.1.6", | |
"rimraf": "^3.0.0", | |
"zip-dir": "^1.0.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment