Lately I have been getting lots of Google Voice and GMail messages, and it can be a royal pain to go through and mark them all read on the web interfaces, so I threw together a couple of script that help to solve this problem from the shell for me.
obj = imaplib.IMAP4_SSL('imap.gmail.com', '993')
typ ,data = obj.search(None,'UnSeen')
print "Messages marked as read"
print "No messages to mark"
from googlevoice import Voice,util
voice = Voice()
while True :
folder = voice.search('is:unread')
if folder.totalSize <= 0 :
for message in folder.messages:
if not message.id:
Now, to tie it all together, a bash script:
echo "Marking text messages read"
~/bin/voice_mark_as_read &> $voice_file &
echo "Marking gmail messages read"
~/bin/gmail_mark_as_read &> $gmail_file &
rm $gmail_file $voice_file
Now, I do not claim to be the original author of the first 2 scripts here, they were taken from various stack exchange posts and what not (I lost the URLs and I have modified the scripts, so unfortunately I cannot give due credit, but I will not take it for myself). The last bash script was my little work, and it does its job perfectly. I hope this helps someone else to fix the problem that I was also facing.