From 2114afd61ac36f27a4212aaddd232d0003a3af31 Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Tue, 4 Jan 2022 20:26:02 +0200 Subject: [PATCH] add script to archive tracks that were moved --- archiveexported.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 archiveexported.js diff --git a/archiveexported.js b/archiveexported.js new file mode 100644 index 0000000..e4bc0e1 --- /dev/null +++ b/archiveexported.js @@ -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);