改一下漫画

凑合用

var fs = require("fs")

var files = fs.readdirSync(__dirname);

files.forEach(function(ele){
  if(!/js$/g.test(ele)){
    var info = __dirname + "\\" + ele
    var purfile = fs.readdirSync(info)
  }

  var bookname = ele

  if(Array.isArray(purfile)){
    purfile.forEach(function(ele){
      var name = parseInt(ele)
      if(name.toString().length === 1){
        var filepath = __dirname  + '\\' + bookname + '\\' + ele
        var filename =  '0' + name.toString() + '.jpg'
        var newfilepath = __dirname  + '\\' + bookname + '\\' + filename


        fs.rename(filepath, newfilepath, function(err) {
            if (err) throw err;

            console.log(' ok~');
        });
      }
    })
  }

})

你可能感兴趣的:(改一下漫画)