Created
September 17, 2017 00:31
-
-
Save alice-em/b74e13c3dac07c95fe1d5d13d78a0aff to your computer and use it in GitHub Desktop.
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
| // comic-copier.js | |
| const fs = require('fs') | |
| const os = require('os') | |
| const path = require('path') | |
| const sander = require('sander') | |
| const input = '/path/from/' | |
| const output = '/path/to' | |
| const comics = ['.cbr', '.cbz', '.cbt'] | |
| const copier = (input, output) => { | |
| let files = fs.readdirSync(input) | |
| for (let i = 0; i < files.length; i++) { | |
| let file = path.join(input, files[i]) | |
| let stat = fs.statSync(file) | |
| if (stat.isDirectory()) { | |
| copier(file, output) | |
| } else if (stat.isFile() && comics.indexOf(path.extname(file)) > -1) { | |
| console.log(`[${i}/${files.length}]Copying File: ${path.join(output, files[i])}`) | |
| sander.copyFileSync(file).to(path.join(output, files[i])) | |
| } | |
| } | |
| } | |
| copier(input, output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment