#!/usr/bin/env node
var glob = require('glob');
var fs = require('fs');

function pad(num, size) {
  var str = num.toString();
  while (str.length < size) {
    str = '0' + str;
  }
  return str;
}

glob(__dirname + '/../data/slide/*.md', function (err, files) {
  if (err) { return console.log(err); }
  files.sort();
  files.forEach(function (file, index) {
    var newFile = file.replace(/\d\d\d/, pad((index + 1) * 10, 3));
    fs.rename(file, newFile, function () {
      console.log(file, '→', newFile);
    });
  });
});
