Skip to content

Instantly share code, notes, and snippets.

@findscode
Created July 5, 2021 18:40
Show Gist options
  • Save findscode/84560cfbd30903f033d7c1a292e2d59e to your computer and use it in GitHub Desktop.
Save findscode/84560cfbd30903f033d7c1a292e2d59e to your computer and use it in GitHub Desktop.
A track name beautifier used by me to manage around 1k of Liquid D&B files
const fs = require('fs');
const path = require('path');
const directory = './Liquid';
(async () => {
const files = await fs.promises.readdir(directory);
for (const file of files) {
const name = file
.replace(/^[0-9]+\ - /, '')
.replace(/ +(?= )/g, '')
.replace(/ *\[[^)]*\] */g, '')
.replace('feat ', 'ft ')
.replace('ft ', 'ft. ')
.replace('Ft.', 'ft.')
.replace('_-_', ' - ')
.replace('_', '')
.replace('—', '-');
await fs.promises.rename(path.join(directory, file), path.join(directory, name));
console.log(`[${file}] -> (${name})`);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment