Rename traits
unknown
javascript
4 years ago
621 B
6
Indexable
const fs = require('fs'); const [, , ...args ] = process.argv const path = ("./" + args[0]) || './' console.log(path) const percentages = [ 1.00, 3.00, 4.00, ] fs.readdir(path, (err, files) => { files.filter(f => f.endsWith('.png')).forEach((file,idx) => { console.log(file); const ext = file.split('.').pop(); const nameWithoutExt = file.substring(0, file.length - ext.length - 1); const formattedName = nameWithoutExt.replace(/-/g, ' '); const newname = `${path}/${formattedName}#${percentages[idx]}.${ext}`; console.log("New name: ", newname); fs.renameSync(`${path}/${file}`, newname); }); });
Editor is loading...