Last active
July 22, 2021 16:36
-
-
Save mrhm-dev/99cd3d538910529940cfbd7181adda20 to your computer and use it in GitHub Desktop.
Rename bulk amount of files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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