logo

Grimgrains

[mirror] Plant-based cooking website <https://grimgrains.com/>

renamer.js (388B)


  1. const testFolder = '.';
  2. const fs = require('fs');
  3. fs.readdir('.', (err, files) => {
  4. files.forEach(file => {
  5. const ext = file.split('.')[file.split('.').length-1]
  6. const filename = file.replace(`.${ext}`,'').replace(/\./g,'_')
  7. fs.rename(file, filename+'.png', function(err) {
  8. if ( err ) console.log('ERROR: ' + err);
  9. });
  10. console.log(filename,ext);
  11. });
  12. });