Skip to content

Instantly share code, notes, and snippets.

@ngokevin
Created June 8, 2020 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngokevin/19f002a64ae0026539bbd0085fb0c962 to your computer and use it in GitHub Desktop.
Save ngokevin/19f002a64ae0026539bbd0085fb0c962 to your computer and use it in GitHub Desktop.
Hakuneko Manga Combiner
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);
});
{
"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