-
Notifications
You must be signed in to change notification settings - Fork 1
/
extract.js
executable file
·37 lines (26 loc) · 1.07 KB
/
extract.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
var fs = require("fs");
var shell = require("shelljs");
var config = require("./config");
if (!config.imageFileTypes && !config.videoFileTypes) {
console.log("no 'imageFileTypes' or 'videoFileTypes' set in config.json... doing nothing.");
}
if (!config.imageDestinationFolder && !config.videoDestinationFolder) {
console.log("no 'imageDestination' or 'videoDestination' set in config.json... doing nothing.");
}
if (config.imageFileTypes && config.imageDestinationFolder) {
extractFiles(config.imageFileTypes, config.sourceFolder, config.imageDestinationFolder);
}
if (config.videoFileTypes && config.videoDestinationFolder) {
extractFiles(config.videoFileTypes, config.sourceFolder, config.videoDestinationFolder);
}
function extractFiles(type, source, destination){
for (var i = 0; i < type.length; i++) {
console.log("Let's find all the ", type[i], "...")
var command = 'EXTENSION=' + type[i]
+ ' MOVE="' + config.moveFiles + '"'
+ ' SOURCE="' + source + '"'
+ ' DESTINATION="' + destination + '"'
+ ' ./extract.sh';
shell.exec(command);
}
}