-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfolder-nfo-checker.js
68 lines (44 loc) · 1.44 KB
/
folder-nfo-checker.js
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const FS = require('fs');
const Path = require('path');
const Glob = require('glob')
const FOLDER = process.argv[2]
if ( !FOLDER ) {
console.log('need folder specified');
process.exit(1);
}
async function loopFolder(fld) {
console.log('reading dir', fld);
const folders = FS.readdirSync(fld);
console.log('read', folders.length, 'items');
for ( const [i, folder] of folders.entries() ) {
const perc = parseInt(i * 100 / folders.length, 10);
process.stdout.clearLine();
process.stdout.cursorTo(0);
process.stdout.write( `${perc}% | ${folder}` );
const fullpath = Path.join(fld, folder);
const stat = FS.statSync( fullpath );
if ( stat.isDirectory() ) {
const requestedFiles = Glob.globSync(['*.nfo', '*fanart.{png,jpeg,jpg}', '*poster.{png,jpeg,jpg}'], {cwd: fullpath});
let tot = 0;
for ( const file of requestedFiles ) {
// const filepath = Path.join(fullpath, file);
const ext = Path.extname( file );
for ( const reqExt of ['.nfo', '.jpg', '.png', '.jpeg']) {
if ( ext == reqExt ) {
tot++;
break;
}
}
}
if ( tot < 3 ) {
process.stdout.clearLine();
process.stdout.cursorTo(0);
console.log( `"${folder}"` , 'could be missing required files:', requestedFiles);
}
}
}
process.stdout.clearLine();
process.stdout.cursorTo(0);
console.log('');
}
loopFolder(FOLDER);