Skip to content

Instantly share code, notes, and snippets.

@dacer
Forked from kfatehi/1pass_dups.js
Last active August 12, 2022 12:30
Show Gist options
  • Save dacer/df67399c8493b3250f2c8f9755b03e32 to your computer and use it in GitHub Desktop.
Save dacer/df67399c8493b3250f2c8f9755b03e32 to your computer and use it in GitHub Desktop.
1password duplicate remover
// 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