Skip to content

Instantly share code, notes, and snippets.

@mrhm-dev
Last active July 22, 2021 16:36
Show Gist options
  • Save mrhm-dev/99cd3d538910529940cfbd7181adda20 to your computer and use it in GitHub Desktop.
Save mrhm-dev/99cd3d538910529940cfbd7181adda20 to your computer and use it in GitHub Desktop.
Rename bulk amount of files
const fs = require('fs');
const path = require('path');
const filePath = '/Users/hmnayem/Desktop/Demo';
const files = fs.readdirSync(filePath).filter((file) => file.endsWith('.png'));
let count = 54;
const extName = '.png';
files.forEach((file) => {
const oldPath = path.join(filePath, file);
const newPath = path.join(filePath, count + extName);
fs.renameSync(oldPath, newPath);
console.log('Done', count, '...');
count++;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment