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.nethttp://rb-appscript.rubyforge.org