spotifylookup/archiveexported.js

27 lines
726 B
JavaScript

const fs = require('fs/promises');
const path = require('path');
const targetMediaDir = path.resolve(process.argv[2]);
const selectionFile = process.argv[3]
? path.resolve(process.argv[3])
: path.join(__dirname, 'track-selection.json');
async function readSelection() {
let discardFiles = [];
await fs.mkdir(targetMediaDir, { recursive: true });
const content = JSON.parse(await fs.readFile(selectionFile));
content.forEach((item) => {
discardFiles.push(item[0]);
});
for (const file of discardFiles) {
await fs.rename(file, path.join(targetMediaDir, path.basename(file)));
}
console.log('Moved %d files to', discardFiles.length, targetMediaDir);
}
readSelection().catch(console.error);