gd-utils/dedupe

27 lines
925 B
Plaintext
Raw Normal View History

2020-06-27 14:19:43 +08:00
#!/usr/bin/env node
const { argv } = require('yargs')
2020-07-07 19:15:49 +08:00
.usage('用法: ./$0 <folder-id> [options]')
2020-07-30 17:43:16 +08:00
.alias('y', 'yes')
.describe('yes', '如果發現重複項目,直接刪除')
2020-06-27 14:19:43 +08:00
.alias('u', 'update')
2020-07-07 20:41:02 +08:00
.describe('u', '不使用本地快取,則無視快取記錄強制從線上獲取源資料夾資訊')
2020-06-27 14:19:43 +08:00
.alias('S', 'service_account')
2020-07-07 20:41:02 +08:00
.describe('S', '使用service account進行操作前提是必須在 ./sa 目錄下存放sa授權json文件')
2020-06-27 14:19:43 +08:00
.help('h')
.alias('h', 'help')
const { dedupe, validate_fid } = require('./src/gd')
const [fid] = argv._
if (validate_fid(fid)) {
const { update, service_account } = argv
dedupe({ fid, update, service_account }).then(info => {
if (!info) return
const { file_count, folder_count } = info
2020-07-07 20:41:02 +08:00
console.log('任務完成,共刪除檔案數:', file_count, '目錄數:', folder_count)
2020-06-27 14:19:43 +08:00
})
} else {
2020-07-07 20:41:02 +08:00
console.warn('無目錄ID或格式錯誤')
2020-06-27 14:19:43 +08:00
}