Print Mail Rules?
source link: https://forums.macrumors.com/threads/print-mail-rules.2336495/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Print Mail Rules?
Got a tip for us? Let us know
Oct 2, 2015
I would like to peruse and organize my long list.
One nice thing about using Thunderbird was that the mail filters were stored a a human-readable ASCII file.
Artiste212
macrumors member
Aug 26, 2012
Download Owl OCR and use the free version to take a screnshot and use it's OCR to convert to text or a readable PDF. Either way, you can copy the rules text to another document.
Jul 1, 2014
3,712
1,916
Spotlight search should find it, or from Terminal: find ~/Library/Mail -type f -iname '*rule*.plist'
Now, the plist will be in XML format, so won't be a straight forward read.
Oct 2, 2015
~/Library/Mail/V9/MailData
as
- SyncedRules.plist
- RulesActiveState.plist
- UnsyncedRules.plist
/usr/libexec/PlistBuddy -c print <filename>
or
/usr/bin/plutil -p <filename>
can show human-readable contents but I cannot find anything that parses the files into nicely formatted text as in the rule definitions themselves. I guess that what I want to see may require code to parse multiple plist files, as the Mail program does. Perhaps someone has written such a utility?
BrianBaughn
macrumors G3
Maybe someone can do a test.
Oct 2, 2015
Since I am primarily interested seeing the Rules name and destination folder for each rules, I wrote a simple shell script to parse the syncedRules.plist file and print out this info. This works because the plist file has the Rules in the order they are applied. The script just parses the plist file without using PlistBuddy or plutil, although the script would have been simpiler using either of these utilities.
Although others may think me nuts for having about 300 Mail rules, I've been dealing with email this way for ~40 years and don't want to change now...
Artiste212
macrumors member
Aug 26, 2012
Could you post the script you wrote? I've held off on writing many more rules because worried I'd lose track of them.It would be nice to be able to print out all the Rules as you see them in Preferences, but I have what I need for now.
Since I am primarily interested seeing the Rules name and destination folder for each rules, I wrote a simple shell script to parse the syncedRules.plist file and print out this info. This works because the plist file has the Rules in the order they are applied. The script just parses the plist file without using PlistBuddy or plutil, although the script would have been simpiler using either of these utilities.
Although others may think me nuts for having about 300 Mail rules, I've been dealing with email this way for ~40 years and don't want to change now...
I have about 50 rules in Gmail, and I've copied and pasted them all into a spreadsheet. Interestingly, Google doesn't guarantee they are executed in order, so although they have the advantage of being server-side, they're not really as useful as they could be. I've also noticed that they don't always work -- maybe about 98% of the time they do.
I mainly take advantage of Gmail's categories and assign standard labels to email in each category. This allows separating my Apple Mail inbox into primary, updates, and promotions. I've let this happen in Gmail for two reasons:
1. I didn't want to write another 70 rules in Apple Mail without being able to view them all clearly
2. Sometimes I'm at work using only a required PC, and need to read my personal email. I need Gmail to be usable in that context.
Oct 2, 2015
It is an 'old-school' sh shell script and assumes that your Rules syncedRules and UnsyncedRules plist files are in the default location.
So if your data are in another location you need to change the line
inDir=~/Library/Mail/V9/MailData
The usage is very simple from the CLI. If you provide an arg, it will parse Unsynced Rules, otherwise your user-defined.
YMMV, so user beware. At least it should do no harm as it is read-only.
Just download and put in your execution path or call directly from Terminal or your favorite shell program.
Output goes to your screen. Example directing output to file:
$ do.showMailRules > MailRules.txt
$ less MailRules.txt
reading from Mail directory: /Users/jw/Library/Mail/V9/MailData
Sat Mar 5 11:02:45 EST 2022
......................................
usps -> imap://jdw.js13%40gmail.com/USPS
bankofamerica.com -> imap://johnwiggins%40mac.com/bankofamerica.com
Tablet -> imap://jdw.js13%40gmail.com/Tablet
...snip...
VUDU Forums -> imap://johnwiggins%40mac.com/VUDU%20forums
WhiteHouse -> imap://johnwiggins%40mac.com/WhiteHouse
me -> imap://johnwiggins%40mac.com/family/me
DELETE MSG ->
Bank of America -> imap://johnwiggins%40mac.com/Bank%20of%20America%20Alert
Junk_ -> Junk
......................................
303 Rules in syncedRules.plist
(/Users/jw/Library/Mail/V9/MailData)
Sat Mar 5 11:03:21 EST 2022
version: do.showMailRules,v 1.3 2022/03/05 12:29:14 jw Exp $
(END)
NOTE: I had to add extension txt in order to get the forum to upload the file so after you download, you should:
mv do.showMailRules.txt do.showMailRules
P.S. If the file is not executable, you will need to
$ chmod 755 do.showMailRules
or similar command from your shell. Once the script is executable, you may see the following error
do.showMailRules reading from Mail directory: /Users/<YourUserName>/Library/Mail/V9/MailData Sun Mar 6 08:55:49 EST 2022 <Path>/do.showMailRules: line 85: /Users/<YourUserName>/Library/Mail/V9/MailData/SyncedRules.plist: Operation not permitted
...snip...
If so, the program you are using to serve up the shell, .e.g. Terminal, iTerm2, XQuartz, does not have permission to view files in ~/Library. To read the plist files, you need configure your server program to have full disk access to read the plist files:
- System Preferences :
- Security & Privacy :
- Full Disk Access :
Attachments
-
do.showMailRules.txt2.3 KB · Views: 5
Reactions: Artiste212
Artiste212
macrumors member
Aug 26, 2012
Thank you very much!Sure, but keep in mind it has very limited functionality to do just what I need.
It is an 'old-school' sh shell script and assumes that your Rules syncedRules and UnsyncedRules plist files are in the default location.
So if your data are in another location you need to change the lineinDir=~/Library/Mail/V9/MailData
The usage is very simple from the CLI. If you provide an arg, it will parse Unsynced Rules, otherwise your user-defined.
YMMV, so user beware. At least it should do no harm as it is read-only.
Just download and put in your execution path or call directly from Terminal or your favorite shell program.
Output goes to your screen. Example directing output to file:$ do.showMailRules > MailRules.txt $ less MailRules.txt reading from Mail directory: /Users/jw/Library/Mail/V9/MailData Sat Mar 5 11:02:45 EST 2022 ...................................... usps -> imap://jdw.js13%40gmail.com/USPS bankofamerica.com -> imap://johnwiggins%40mac.com/bankofamerica.com Tablet -> imap://jdw.js13%40gmail.com/Tablet ...snip... VUDU Forums -> imap://johnwiggins%40mac.com/VUDU%20forums WhiteHouse -> imap://johnwiggins%40mac.com/WhiteHouse me -> imap://johnwiggins%40mac.com/family/me DELETE MSG -> Bank of America -> imap://johnwiggins%40mac.com/Bank%20of%20America%20Alert Junk_ -> Junk ...................................... 303 Rules in syncedRules.plist (/Users/jw/Library/Mail/V9/MailData) Sat Mar 5 11:03:21 EST 2022 version: do.showMailRules,v 1.3 2022/03/05 12:29:14 jw Exp $ (END)
NOTE: I had to add extension txt in order to get the forum to upload the file so after you download, you should:mv do.showMailRules.txt do.showMailRules
Oct 2, 2015
I just did a test download and see you need do the chmod command I just added to my entry.Thank you very much!
Artiste212
macrumors member
Aug 26, 2012
I tried it, but I'm getting this reply: zsh: permission denied: /Users/bruce/do.showMailRules.Sure, but keep in mind it has very limited functionality to do just what I need.
It is an 'old-school' sh shell script and assumes that your Rules syncedRules and UnsyncedRules plist files are in the default location.
So if your data are in another location you need to change the lineinDir=~/Library/Mail/V9/MailData
The usage is very simple from the CLI. If you provide an arg, it will parse Unsynced Rules, otherwise your user-defined.
YMMV, so user beware. At least it should do no harm as it is read-only.
Just download and put in your execution path or call directly from Terminal or your favorite shell program.
Output goes to your screen. Example directing output to file:$ do.showMailRules > MailRules.txt $ less MailRules.txt reading from Mail directory: /Users/jw/Library/Mail/V9/MailData Sat Mar 5 11:02:45 EST 2022 ...................................... usps -> imap://jdw.js13%40gmail.com/USPS bankofamerica.com -> imap://johnwiggins%40mac.com/bankofamerica.com Tablet -> imap://jdw.js13%40gmail.com/Tablet ...snip... VUDU Forums -> imap://johnwiggins%40mac.com/VUDU%20forums WhiteHouse -> imap://johnwiggins%40mac.com/WhiteHouse me -> imap://johnwiggins%40mac.com/family/me DELETE MSG -> Bank of America -> imap://johnwiggins%40mac.com/Bank%20of%20America%20Alert Junk_ -> Junk ...................................... 303 Rules in syncedRules.plist (/Users/jw/Library/Mail/V9/MailData) Sat Mar 5 11:03:21 EST 2022 version: do.showMailRules,v 1.3 2022/03/05 12:29:14 jw Exp $ (END)
NOTE: I had to add extension txt in order to get the forum to upload the file so after you download, you should:mv do.showMailRules.txt do.showMailRules
P.S. If the file is not executable, you will need to$ chmod 755 do.showMailRules
or similar command from your shell.
Terminal has full disk permissions and I have read/write on the file do.showMailRules.
I have read/write permissions for Librar and all the subfolders and files down to the MailData folder. All files are in their original locations.
Perhaps my lesser experience in terminal is causing me to miss something?
Oct 2, 2015
Have you doneI tried it, but I'm getting this reply: zsh: permission denied: /Users/bruce/do.showMailRules.
Terminal has full disk permissions and I have read/write on the file do.showMailRules.
I have read/write permissions for Librar and all the subfolders and files down to the MailData folder. All files are in their original locations.
Perhaps my lesser experience in terminal is causing me to miss something?
chmod 755 /Users/bruce/do.showMailRules
I added this to my post, it occurred to me in the shower. After that you should be able to execute with command
/Users/bruce/do.showMailRules
Artiste212
macrumors member
Aug 26, 2012
Unfortunately, I'm getting the same error message
Artiste212
macrumors member
Aug 26, 2012
I wonder if you have added and new commands to your terminal that allow you to do this but not me?Have you donechmod 755 /Users/bruce/do.showMailRules
I added this to my post, it occurred to me in the shower. After that you should be able to execute with command/Users/bruce/do.showMailRules
adrianlondon
macrumors 68040
tell application "Mail" to get name of rules
There may be ways to get the content of each rule too, but that's beyong my Mail scripting abilities/interest.
Reactions: Artiste212
Oct 2, 2015
Perhaps it is the file ownership. The chmod command I gave makes the file executable by the owner. Please let me know what happens if you make it executable by everyone:I wonder if you have added and new commands to your terminal that allow you to do this but not me?
chmod 777 /Users/bruce/do.showMailRules
and the command should run without any errors. If you don't have permission, try
sudo chmod 777 /Users/bruce/do.showMailRules
and
sudo /Users/bruce/do.showMailRules
which will prompt for your login password.
The only other thing that comes to mind is that I am an Admin user and Apple may have restricted shell script execution for normal users. That does not seem to be the case on Monterey 12.2.1 on my M1 Mac mini as I just logged in as Guest and was able to run the shell script after doing the chmod. The file should be owned by you. The command
ls -l /Users/bruce/do.showMailRules
should show protections "-rwxrwxrwx" and owner "bruce" and you do not need to be in group staff as the chmod command should make that irrevelant. If the file is not owned by bruce you can simply copy it to another file.
-rwxrwxrwx 1 bruce staff 2320 Mar 5 12:13 do.showMailRules.txt
^^^^^^^^^ ^^^^^
I like MacOS because it is just UNIX underneath but UNIX is not for everyone. Hope this gets you going....
Artiste212
macrumors member
Aug 26, 2012
So I redownloaded the file, ran the chmod 755 command again, and this time it worked. No idea what went wrong before, but very happy to have this info. Thanks!Have you donechmod 755 /Users/bruce/do.showMailRules
I added this to my post, it occurred to me in the shower. After that you should be able to execute with command/Users/bruce/do.showMailRules
Oct 2, 2015
IMPORTANT NOTE IF YOU WANT TO USE do.showMailRules shell script on Monterey:So I redownloaded the file, ran the chmod 755 command again, and this time it worked. No idea what went wrong before, but very happy to have this info. Thanks!
I did not see this, as I was writing and using the shell script within XQuartz.
You may see the following error if you try running script using Terminal, iTerm2 or other MacOS program.
If you can execute the script and get the following error:
do.showMailRules
reading from Mail directory: /Users/<YourUserName>/Library/Mail/V9/MailData
Sun Mar 6 08:55:49 EST 2022
<Path>/do.showMailRules: line 85: /Users/<YourUserName>/Library/Mail/V9/MailData/SyncedRules.plist: Operation not permitted
...snip...
If so you need to configure your program to have full disk access to read the plist files:
Reactions: Artiste212
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK