add script to archive tracks that were moved
This commit is contained in:
parent
d4229ce2f8
commit
2114afd61a
26
archiveexported.js
Normal file
26
archiveexported.js
Normal 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);
|
Loading…
Reference in New Issue
Block a user