![Thunderbird logo](https://assets-prod.sumo.prod.webservices.mozgcp.net/media/uploads/products/2024-02-12-07-36-53-599028_1.png)
How can I maintain one set of TB filter rules for all of my accounts?
I maintain multiple email accounts for which I want to run the same filter rules. I mean the *same* rules. Unlike some people in this predicament, I am never moving emails within a folder hierarchy that is only the same as others relative to each account. When I move any particular type of filtered email, those particular messages all go to a folder in a single account, even if they originate in a different account. So, I really do want to run the *same* rules for each account, where each rule will send mails to a single folder. Mind you, though, not each filter that moves a message has to have the same destination account. One filter rule can send all emails to a folder under one account, another filter rule can send emails to a folder under a different account.
Note that I am going to answer my own question. I am doing this because I have seen people troubled by this problem and yet none has received the novel advice I have used to conveniently solve my own problem. All of the questions and answers have also been archived by now, so I cannot offer my novel solution in response to those question. Thus, I am asking the question for myself so I can then share the results with others.
Все ответы (1)
The solution for this is to create a complete set of filters for just one account. Since these rules are stored in a file located in a folder unique to that account, all you need to is create "hard links" of the filter file in the other account folders. You only need to do this once for each account, never again, unless you start using different rules for different accounts.
Here is how to make the hard links.
1. Shut down Thunderbird. Close all TB windows. Make sure you don't have any others open, like alerts or messages you were composing! You can also check Task Manager to see that TB has no processes running.
2. Identify the TB folder for your current profile. For example, in Windows 10, you could expect the folder name to be "C:\Users\<username>\AppData\Roaming\Thunderbird\Profiles\<8-digit random code>.default". If you have more than one folder with a random 8-digit code, choose the folder with the latest modification time (unless you think you modified another profile folder even more recently).
3. Within that folder you just identified, there are sub-folders related to each mail account you have setup in TB (for that profile). Identify the account folder for your one email account that has all of (and the only) rules you want to share with other accounts.
Generally, Windows 10 users would find that folder in "C:\Users\<username>\AppData\Roaming\Thunderbird\Profiles\<8-digit random code>.default\ImapMail\<vendor incoming mail server URL>.
For example, if you had just setup your rules for a Yahoo IMAP account in Windows 10, you could expect to see a folder name like "C:\Users\YourUserName\AppData\Roaming\Thunderbird\Profiles\4b3oc8e9.default\ImapMail\imap.mail.yahoo.com".
4. Identify all of the other folders in your profile that contain your accounts to which you want to apply the same filter rules. For example, if you have a Google account it could be something like "C:\Users\YourUserName\AppData\Roaming\Thunderbird\Profiles\4b3oc8e9.default\ImapMail\imap.gmail.com".
5. **For each of mail account folders you will be sharing those rules with,** delete the msgFilterRules.dat file (or rename it to something like msgFilterRules.dat.bak). (Do NOT do delete the file in the folder which has all the filter rules you want to propagate!)
6. After you have deleted or renamed all of the filter rule files in other account folders, you will create the hard links.
a. Open a Windows command prompt window as administrator (or for another OS, do an equivalent shell operation).
b. Change your directory to the folder with the original "good" filter file (with all the rules you use). For example, "cd C:\Users\<username>\AppData\Roaming\Thunderbird\Profiles\<8-digit random code>.default\ImapMail\<vendor incoming mail server URL>"
c. Make a **hard link** (not just a "shortcut" or "soft/symbolic link") to each additional account folder using the current folder's msgFilterRules.dat file. Use the mklink command with the "h" (for hard) option: "mklink -h ../<additional vendor incoming mail server URL>/msgFilterRule.dat msgFilterRule.dat" {doing this for each additional account needing the same filter rules} E.g., for making a hard link to a Google account from a Yahoo account, it would be "mklink -h ../imap.google.com/msgFilterRule.dat msgFilterRule.dat"
7. Once you have made all the hard links for each account sharing the rules, you will essentially have a single collection of rules to which each account is pointing. Hard links were designed for needs like this! In many similar situations, you could also use soft links, but Thunderbird (for reasons I don't know of) requires hard links.
8. Restart Thunderbird and enjoy the simplicity of the same filter rules shared by multiple accounts.
Note: Every solution I have previously seen offered for this problem has involved making a copy of the original filter file in each additional account folder (or editing the msgFilterRules.dat file and pasting in the rules from another file). However, that solution requires recopying the filter rules file to each account directory **every time the filter rules have changed**. That requirement is an invitation for making mistakes, including forgetting to copy the files after a filter change or only copying the files to certain accounts. I hope this has helped someone, someday. :-)