forked from iwestlin/gd-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdedupe
More file actions
executable file
·26 lines (23 loc) · 920 Bytes
/
dedupe
File metadata and controls
executable file
·26 lines (23 loc) · 920 Bytes
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('用法: ./$0 <folder-id> [options]')
.alias('y', 'yes')
.describe('yes', '若发现重复项,不询问直接删除')
.alias('u', 'update')
.describe('u', '不使用本地缓存,强制从线上获取源文件夹信息')
.alias('S', 'service_account')
.describe('S', '使用service account进行操作,前提是必须在 ./sa 目录下放置sa授权json文件')
.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('任务完成,共删除文件数:', file_count, '目录数:', folder_count)
})
} else {
console.warn('目录ID缺失或格式错误')
}