Skip to content

Instantly share code, notes, and snippets.

@Flyrell
Created September 3, 2021 13:50
Show Gist options
  • Save Flyrell/3858f0f9d7cb0eaf968be619917e79ee to your computer and use it in GitHub Desktop.
Save Flyrell/3858f0f9d7cb0eaf968be619917e79ee to your computer and use it in GitHub Desktop.
#!/usr/local/bin/node
const fs = require('fs');
const path = require('path');
const arguments = process.argv.slice(2);
const folder = arguments[0];
const filePrefix = arguments[1];
const map = {
py: 'u',
pz: 'f',
ny: 'd',
nx: 'l',
px: 'r',
nz: 'b',
};
const files = fs.readdirSync(folder);
for (const file of files) {
const fileName = path.parse(file).name;
if (map[fileName]) {
const suffix = map[fileName];
const newFileName = `${filePrefix}_${suffix}.jpg`;
fs.renameSync(path.join(folder, file), path.join(folder, newFileName));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment