Skip to content

Instantly share code, notes, and snippets.

@kfatehi
Forked from thehesiod/1pass_dups.py
Last active December 25, 2023 00:35
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save kfatehi/122772563b668fa2bbbe03b1cf6e82bc to your computer and use it in GitHub Desktop.
Save kfatehi/122772563b668fa2bbbe03b1cf6e82bc to your computer and use it in GitHub Desktop.
1password duplicate remover (alpha, only run in debugger with breakpoints everywhere *g*)
// you need `op` tool for this, download it here https://support.1password.com/command-line/
// create items.json like so:
// op list items | 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 process.js | xargs -I{} op delete item {}
const items = require('./items.json');
var imap = {};
var dups = [];
function mkhash(item) {
return item.title+item.createdAt+item.updatedAt;
}
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].uuid)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment