Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Modifying Gruber’s Archiving Script

Modifying Gruber’s Archiving Script
Thread Tools
Koralatov
Senior User
Join Date: Jun 2007
Location: Aberdeen, UK
Status: Offline
Reply With Quote
Jan 27, 2009, 04:54 PM
 
So, I know practically nothing about scripting (a smidge of Javascript, and even less PHP), but I’m determined to modify Gruber’s Simple Archiving Script for my own specific use. Grand Theft Code, no doubt, but I’d really like to get it working.

I only have one (IMAP) email account that I use, so I don’t think the “repeat with _acct in imap accounts” section is required.

I have two specific modifications I want to make:
  1. I only want Mail to archive messages that are read, unflagged, and more than 14 days old; and,
  2. I want it to do the same thing in the “Sent” mailbox as well, but moving it to “Archive/Sent” mailbox instead of the “Archive/Inbox” folder.
I think the variable to determine the age of the emails should go where I’ve inserted the line of asterisks into the code. Unfortunately, I have no idea what the variable/instruction would be.

The second modification should be somewhat more straightforward, but I’m not sure how to do it without causing problems. Do I just insert the same code below the first set with the ‘inbox’ references replaced by ‘sent’? And how do I join the two pieces to make it run the inbox portion first, then the sent portion second?

Without further ado, the code I have thus far is:
Code:
set _description to "All unflagged, read messages in “Inbox” and “Sent” will be moved to the corresponding “Archive” mailbox. This action cannot be undone." tell application "Mail" display alert "Archive read messages from “Inbox” and “Sent” folders?" buttons ¬ {"Cancel", "Archive"} cancel button 1 message _description repeat with _acct in imap accounts set _acct_name to name of _acct set _inbox to _acct's mailbox "INBOX" try set _archive_box to _acct's mailbox "Archive/Inbox" on error display alert "No “Inbox” folder found in “Archive” mailbox." return -- Stop the script end try set _msg_list to (every message of _inbox ¬ whose flagged status is false and read status is true) if (_msg_list's length > 0) then ******************************************************* move _msg_list to _archive_box end if end repeat end tell
Perhaps the most important question I can ask is this: can anyone recommend a really good book to learn Apple Script from?

Thanks in advance.

Edit: One final question I forgot to ask: is there any way of making the script run automatically every day at a set time?
( Last edited by Koralatov; Jan 27, 2009 at 04:55 PM. Reason: Additional question added.)
     
   
Thread Tools
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 06:56 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,