gd-utils/dedupe

27 lines
925 B
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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 } = argv
dedupe({ fid, update, service_account }).then(info => {
if (!info) return
const { file_count, folder_count } = info
console.log('任務完成,共刪除檔案數:', file_count, '目錄數:', folder_count)
})
} else {
console.warn('無目錄ID或格式錯誤')
}