How to clean up old notes left in the Gmail account by

I keep my notes synced with my Gmail account.

In Gmail, I can see all my current notes in the Notes label and associated sublabels.

I can also see many older versions of current notes, and previously-deleted notes, not attached to any label.

Is there any search I can do in Gmail which will reliably find all messages that were created by, so that I can delete old versions / "deleted" notes permanently? (I can find individual notes by searching for their subject line, but I no longer remember all the subject lines of all the notes I've deleted, and I can't find any search string that will reliably find notes which no longer have the Notes label.)

Relatedly: is there any way I can configure so that when it removes a note (or older version of a note) from the Notes label (or a sublabel) it moves it into the trash, rather than leaving it cluttering up my messages archive?

Best Answer

It appears that the following search will find all messages created by, and, for me at least, no messages not created by it: -in:drafts -in:sent -in:chats -l:SMS

(Where username is my Gmail username. The SMS label is used by the SMS Backup+ android app, which stores SMS messages in Gmail in a similar way to, albeit under a different label.)

To find messages which are no longer "live" in (i.e., are older versions or deleted notes), and also exclude any other labels like SMS, use "-has:userlabels", like this: -in:drafts -in:sent -in:chats -has:userlabels 

N.B.: For me the results are 100% old or deleted notes, but this search will find any other messages created in the same way (i.e., via the IMAP interface, with your address in the from field) so have a look through the search results carefully before doing any mass deletions, just to be on the safe side!