filter on gmail code example
Example: how to apply filter gmail
Go to the list of filters in Settings, edit the filter you want to run, don't change anything, and before you click Update filter, check the box that says "Also apply filter to [x] matching conversations".