How to use Applescript to delete Conversations whose senders contain email addresses from the Messages app -
i want use applescript delete conversations people sent me messages using email addresses. want keep conversations mobile numbers, delete conversations, in correspondent email address.
i've tried:
tell application "messages" tell every item delete (every item sender contains ".com") end tell save end tell
all scriptable applications have applescript dictionary can accessed script editor via window --> library menu. reading through application's dictionary can obtain proper terms generating script bidding.
the script below create list of chat ids of chats (conversations) wherein @ least 1 participant using email address. have not tested delete section, since not interested in deleting anything. recommend run time machine or backup service before executing portion of script, in case unexpected results.
set chatstokill {} tell application "messages" set allchats every chat repeat eachchat in allchats set thepeeps participants of eachchat repeat oneparticipant in thepeeps if oneparticipant's handle contains "@" if chatstokill not contain eachchat's id set end of chatstokill eachchat's id end if end repeat end repeat repeat deathchat in chatstokill delete item 1 of (get every chat id = deathchat) end repeat end tell
Comments
Post a Comment