-
-
Save dacer/df67399c8493b3250f2c8f9755b03e32 to your computer and use it in GitHub Desktop.
1password duplicate remover
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// tested on 1Password CLI 2.6.1 (build #2060102) | |
// you need `op` tool for this, download it here https://app-updates.agilebits.com/product_history/CLI2 | |
// create items.json like so: | |
// op item list --format=json | jq > items.json | |
// then run this script | |
// this script outputs uuids of dupes as keyed by item title, create, and modified date, | |
// feed it into the delete command like so: | |
// node 1pass_dups_v2.js | xargs -I {} op item delete {} --archive | |
// and your duplicate items will be moved to the Archive. | |
const items = require('./items.json'); | |
var imap = {}; | |
var dups = []; | |
function mkhash(item) { | |
return item.title+item.created_at+item.updated_at; | |
} | |
for (var i=0; i<items.length; i++) { | |
var item = items[i]; | |
if (item.trashed === "Y") | |
continue; | |
var hash = mkhash(item) | |
if (imap[hash]) { | |
dups.push(item); | |
} else { | |
imap[hash] = item; | |
} | |
} | |
for (var i=0; i<dups.length; i++) { | |
console.log(dups[i].id) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment