otsune's SnakeOil RSSフィード

python -c "print''.join([chr(x) for x in 111&1101,110+~-~11,10^11*11,110+~-~11,-~101,-~11^11*11,~-110,111&11*11,11+11+10,11|~-0110,1-~11^11*11,10^11*11,-~11^11*11,110,101])"

2007-03-02

AppleのMail.appでbloglines読むのが溜まりすぎたので、既読を削除するAppleScript書いた

| AppleのMail.appでbloglines読むのが溜まりすぎたので、既読を削除するAppleScript書いた - otsune's SnakeOil  を含むブックマーク はてなブックマーク - AppleのMail.appでbloglines読むのが溜まりすぎたので、既読を削除するAppleScript書いた - otsune's SnakeOil  AppleのMail.appでbloglines読むのが溜まりすぎたので、既読を削除するAppleScript書いた - otsune's SnakeOil  のブックマークコメント

bloglinesGmailで読んでいたけど、スピードが遅いのでMail.appに変えて数ヶ月。そろそろ読んだメールが10万通を超えたので削除することに。

いままでも適度に手作業で削除していたけど、あんまり大量に溜まると選択するだけでも凄い時間がかかるので。

あと何でかよく分からんが、Mail.appのルールには「メッセージを読んだ」という項目がないので、ルールで自動的にゴミ箱に入れる事が出来ない。ダサい。

AutomatorのMail.appバインドのフィルターには有るのだが。でもAppleEvent経由でメッセージを取り出して、そこにフィルターをかけるので10万通だとタイムアウトしてしまう。

ということで、ルールで「すべてのメッセージ」を以下のAppleScriptを実行することで対処。

using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		tell application "Mail"
			set selCount to (count of theMessages)
			repeat with counter from 1 to selCount
				set msg to item counter of theMessages
				if (read status of msg) is true then
					delete msg
				end if
			end repeat
		end tell
	end perform mail action with messages
end using terms from

本当は

using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		tell application "Mail"
			repeat with eachMessage in theMessages
				try
					if (read status of eachMessage) is true then
						delete eachMessage
					end if
				end try
			end repeat
		end tell
	end perform mail action with messages
end using terms from

でも良いはずなんだけど。

追記

using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		tell application "Mail"
			set max_value to number of items in theMessages
			repeat with i from 1 to max_value
				set this_item to item i of theMessages
				if (read status of this_item) then
					delete this_item
				end if
			end repeat
		end tell
	end perform mail action with messages
end using terms from

item n of theMessagesからid参照を引くのが重いので、ループ中は一回で済むようにした。

トラックバック - http://subtech.g.hatena.ne.jp/otsune/20070302