forked from iwestlin/gd-utils
-
Notifications
You must be signed in to change notification settings - Fork 39
/
dedupe
executable file
·26 lines (23 loc) · 989 Bytes
/
dedupe
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
#!/usr/bin/env node
const { argv } = require('yargs')
.usage('Usage: ./$0 <folder-id> [options]')
.alias('y', 'yes')
.describe('yes', 'If duplicate items are found, delete them without asking')
.alias('u', 'update')
.describe('u', 'Do not use local cache, force to obtain source folder information online')
.alias('S', 'service_account')
.describe('S', 'Use service account to operate, provided that the sa authorized json file must be placed in the ./sa directory')
.help('h')
.alias('h', 'help')
const { dedupe, validate_fid } = require('./src/gd')
const [fid] = argv._
if (validate_fid(fid)) {
const { update, service_account, yes } = argv
dedupe({ fid, update, service_account, yes }).then(info => {
if (!info) return
const { file_count, folder_count } = info
console.log('The task is completed, the total number of deleted files:', file_count, 'Number of Folders:', folder_count)
})
} else {
console.warn('FolderID is wrong or invalid')
}