Talk About Network

Google




Programming > Applescript > Re: Delete msgs...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 4 Topic 1551 of 1697
Post > Topic >>

Re: Delete msgs from junk folder / data structures in apple script

by has <has.temp3@[EMAIL PROTECTED] > Dec 29, 2007 at 05:21 AM

On 27 Dec, 18:40, Achim Domma <do...@[EMAIL PROTECTED]
> wrote:

> I have too much messages in my junk folder and
> want to delete messages which have subjects which appear more than
> once.

> But I could not find any infos about
> dictionary like data structures in apple script.

Doesn't have one. There are various workarounds/solutions to this, but
since you already know Python the easiest thing would just be to use
that. Example:

#!/usr/bin/python

from appscript im****t * # from <http://appscript.sourceforge.net>

threshold = 2 # your value here

mail = app('Mail')

subjects = mail.junk_mailbox.messages.subject.get()

subjectcount = {}

for name in subjects:
    name = name.lower()
    if name in subjectcount:
        subjectcount[name] += 1
    else:
        subjectcount[name] = 1

for name, count in subjectcount.items():
    if count > threshold:
        mail.junk_mailbox.messages[its.subject == name].delete()
        print 'Deleted %i junk messages named %r' % (count, name)


HTH

has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
 




 4 Posts in Topic:
Delete msgs from junk folder / data structures in apple script
Achim Domma <domma@[EM  2007-12-27 10:40:12 
Re: Delete msgs from junk folder / data structures in apple scri
has <has.temp3@[EMAIL   2007-12-29 05:21:46 
Re: Delete msgs from junk folder / data structures in apple scri
Achim Domma <domma@[EM  2008-01-13 06:05:45 
Re: Delete msgs from junk folder / data structures in apple scri
has <has.temp3@[EMAIL   2008-01-13 14:03:18 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Mon Jan 5 22:42:14 PST 2009.