-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrename-icons.js
34 lines (30 loc) · 918 Bytes
/
rename-icons.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
* notion-icons
* (c) 2019 jayhxmo (https://jaymo.io/)
* under the MIT license
*/
const fs = require('fs');
const args = process.argv.slice(2);
if (args[0]) {
const iconDirectory = args[0].slice(-1) == '/' ? args[0].slice(0, args[0].length - 1) : args[0];
let iconCounter = 0,
iconSetName = iconDirectory.split('/').pop();
fs.readdirSync(iconDirectory).forEach(file => {
const fileExtension = file.split('.').pop();
if (
fileExtension == 'png' ||
fileExtension == 'jpeg' ||
fileExtension == 'jpg' ||
fileExtension == 'gif' ||
fileExtension == 'svg'
) {
const sourceFile = `${iconDirectory}/${file}`,
newFile = `${iconDirectory}/${iconSetName}_${iconCounter}.${fileExtension}`;
console.log('Renaming ', sourceFile, ' -> ', newFile);
fs.renameSync(sourceFile, newFile);
iconCounter++;
}
});
} else {
console.log('please include the icon folder name (e.g. FC)');
}