-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (26 loc) · 838 Bytes
/
index.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
#! /usr/bin/env node
var fs = require('fs');
const path = require('path');
const args = require('yargs')
.default('p', '../')
.default('o', 'sorted')
.argv;
const walk = require('./lib/walk');
const dump = require('./lib/dump');
const searchPath = path.join(__dirname, args.p);
const outputPath = path.join(__dirname, args.p, args.o);
console.log(`Sorting ${searchPath} -> ${outputPath}`);
const pattern = /\.(jpg|png|gif|flv|mov|mpg|mp4)\b/i; // larger files
// const pattern = /\.(jpg|png|gif)\b/i; // smaller files
walk(searchPath, pattern, (error, results) => {
if (error) {
throw error;
}
dump(outputPath, results, (error, results) => {
if (error) {
console.log('error!');
return;
}
console.log(`Success. Copied ${results.sortCount}`);
});
});