Skip to content

Instantly share code, notes, and snippets.

@alice-em
Created September 17, 2017 00:31
Show Gist options
  • Select an option

  • Save alice-em/b74e13c3dac07c95fe1d5d13d78a0aff to your computer and use it in GitHub Desktop.

Select an option

Save alice-em/b74e13c3dac07c95fe1d5d13d78a0aff to your computer and use it in GitHub Desktop.

Revisions

  1. alice-em created this gist Sep 17, 2017.
    28 changes: 28 additions & 0 deletions comic-copier.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    // 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)