Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 6A509431FBC for ; Thu, 3 Dec 2009 05:39:35 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qamq9D65VHJG for ; Thu, 3 Dec 2009 05:39:34 -0800 (PST) Received: from pivot.cs.unb.ca (pivot.cs.unb.ca [131.202.240.57]) by olra.theworths.org (Postfix) with ESMTP id C2811431FAE for ; Thu, 3 Dec 2009 05:39:34 -0800 (PST) Received: from localhost ([127.0.0.1] helo=pivot.cs.unb.ca ident=bremner) by pivot.cs.unb.ca with esmtp (Exim 4.69) (envelope-from ) id 1NGBuA-0002jv-4b for notmuch@notmuchmail.org; Thu, 03 Dec 2009 09:39:34 -0400 Date: Thu, 03 Dec 2009 09:39:32 -0400 Message-ID: <87zl60xjl7.wl%bremner@pivot.cs.unb.ca> From: david@tethera.net To: notmuch@notmuchmail.org User-Agent: EMIKO/1.14.1 (Choanoflagellata) FLIM/1.14.9 (=?UTF-8?B?R29q?= =?UTF-8?B?xY0=?=) APEL/10.7 EasyPG/1.0.0 Emacs/23.1 (i486-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by EMIKO 1.14.1 - "Choanoflagellata") Content-Type: multipart/mixed; boundary="Multipart_Thu_Dec__3_09:39:32_2009-1" X-Sender-Verified: bremner@pivot.cs.unb.ca Subject: [notmuch] hack to retag a directory X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Dec 2009 13:39:35 -0000 --Multipart_Thu_Dec__3_09:39:32_2009-1 Content-Type: text/plain; charset=US-ASCII I think this will be obsolete pretty soon when the equivalent is built-in to notmuch, but in the mean time, here is a script that somebody might find useful: retag a whole directory (recursively). I don't claim it is nice in any way, but it seems usable for me, taking about 5 seconds to retag a directory containing 1000 messages. I use it like tagdir Maildir/.list.debian-devel -inbox +debian +devel --Multipart_Thu_Dec__3_09:39:32_2009-1 Content-Type: application/octet-stream Content-Disposition: attachment; filename="tagdir" Content-Transfer-Encoding: 7bit #!/usr/bin/perl # Copyright © David Bremner # Distributed under the WTFPL # usage: $0 directory tags use strict; my $batchsize=200; my $count=0; my $dir=$ARGV[0]; shift(@ARGV); my @tags=@ARGV; my @msg_ids=(); open (ID, "grep -h -R '^Message-I[dD]' $dir|") || die "$!"; while(){ chomp(); s/[\<\>]//g; s/([;<>\*\|`&\$!#\(\)\[\]\{\}:'"])/\\$1/g; s/^Message-I[dD]: /id:/; push(@msg_ids,$_); $count++; if ($count>=$batchsize){ $count=0; system("notmuch tag ".join(" ",@tags)." ".join(" or ", @msg_ids)); @msg_ids=(); } } system("notmuch tag ".join(" ",@tags)." ".join(" or ", @msg_ids)); --Multipart_Thu_Dec__3_09:39:32_2009-1 Content-Type: text/plain; charset=US-ASCII --Multipart_Thu_Dec__3_09:39:32_2009-1--