Created
April 25, 2020 09:47
-
-
Save masumskaib396/37876748b875d78f7432e4c0e981d225 to your computer and use it in GitHub Desktop.
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 = 'file path name'; | |
const files = fs.readdirSync(filePath).filter((file) => file.endsWith('.png')); | |
let count = 1; | |
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