add script to archive tracks that were moved

This commit is contained in:
Evert Prants 2022-01-04 20:26:02 +02:00
parent d4229ce2f8
commit 2114afd61a
Signed by: evert
GPG Key ID: 1688DA83D222D0B5

26
archiveexported.js Normal file
View File

@ -0,0 +1,26 @@
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);