Created
October 5, 2017 02:16
-
-
Save shioken/bd9aac2bd1679f63c34f933419978169 to your computer and use it in GitHub Desktop.
Rename to sequence number
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
var fs = require('fs'); | |
fs.readdir('.', function(err, files) { | |
if (err) throw err; | |
var fileList = []; | |
var index = 0; | |
files.filter(function(file) { | |
return fs.statSync(file).isFile() && /.*snapshot\.jpg$/.test(file); | |
}).forEach(function(file) { | |
var newfilename = 'image_' + ('000' + index).slice(-4) + ".jpg"; | |
fs.renameSync(file, newfilename); | |
index++; | |
// fileList.push(file); | |
console.log(file, newfilename); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment