Jump to content

Remove several clipboard history items by criteria?

Recommended Posts

Is it possible to remove several clipboard history items at once? I would for example like to be able to occasionally, on demand, be able to remove all clipboard history text items < 3 characters long. I know I can fn-delete individual items in the list, but I'd like to be able to perhaps activate a workflow to prune the clipboard history list en masse. Any ideas? Possible?

Link to post

@effe While this isn't possible natively in Alfred, the clipboard database is actually just an SQLite DB, so with a bit of scripting, you should be able to quite easily manipulate the database. You'll find the clipboard db in the following location:


~/Library/Application\ Support/Alfred\ 3/Databases/clipboard.alfdb


The database has one table (clipboard) with the following columns:


clipboard(item, ts decimal, app, apppath, dataType integer, dataHash);


The text data is stored in the "item" column, and you'd probably want to only touch items with dataType = 0 as this is text items. Other items have external dependencies outside the database, such as images.


Also worth adding that you fettle with this at your own (low) risk. The worst thing that could happen is you lose your history and have to start again.





Link to post
  • 6 months later...

Thank you. Apologies for not following up. I did end up just making a simple script that I run periodically to clear out short history items:


#!/usr/bin/env bash


sqlite3 "${HOME}/Library/Application Support/Alfred 3/Databases/clipboard.alfdb" <<STATEMENT
  DELETE FROM clipboard
  WHERE datatype = 0 AND
        LENGTH(TRIM(item)) <= $threshold;

echo "text clipboard items with length <= $threshold removed from Alfred history"


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...