-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatch_create_file_cards.js
More file actions
executable file
·41 lines (34 loc) · 1.63 KB
/
batch_create_file_cards.js
File metadata and controls
executable file
·41 lines (34 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// batch_create_file_cards.js
// Usage: node batch_create_file_cards.js --page-size LARGE_TAROT --root-dir ../SlackExporterForOmata
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const args = require('minimist')(process.argv.slice(2));
const pageSize = args['page-size'] || 'LARGE_TAROT';
const rootDir = args['root-dir'] || '../SlackExporterForOmata';
const outputDir = args['output-dir'] || 'cards_output';
const borderWidth = args['border-inch-width'] || 0.125;
const borderColor = args['border-color'] || '250,250,250';
if (!fs.existsSync(rootDir)) {
console.error(`Root directory not found: ${rootDir}`);
process.exit(1);
}
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, { recursive: true });
}
const channelDirs = fs.readdirSync(rootDir).filter(dir => {
const fullPath = path.join(rootDir, dir);
return fs.statSync(fullPath).isDirectory() && fs.existsSync(path.join(fullPath, 'files'));
});
channelDirs.forEach(channel => {
const inputDir = path.join(rootDir, channel, 'files');
const channelOutputDir = path.join(outputDir, `${channel}_file_cards_output`);
console.log(`Processing channel: ${channel}`);
const cmd = `python3 create_file_cards.py --page-size "${pageSize}" --input-dir "${inputDir}" --output-dir "${channelOutputDir}" --cmyk-mode --max-depth 2 --border-color "${borderColor}" --delete-cards-after-pdf --exclude-file-path --border-inch-width ${borderWidth}`;
try {
execSync(cmd, { stdio: 'inherit' });
} catch (err) {
console.error(`Error processing channel ${channel}:`, err.message);
}
});
console.log('Batch card creation complete.');