unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* hack to retag a directory
@ 2009-12-03 13:39 david
  2009-12-03 19:26 ` david
  0 siblings, 1 reply; 5+ messages in thread
From: david @ 2009-12-03 13:39 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 409 bytes --]


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


[-- Attachment #2: tagdir --]
[-- Type: application/octet-stream, Size: 681 bytes --]

#!/usr/bin/perl
# Copyright © David Bremner <david@tethera.net>
# Distributed under the WTFPL <http://sam.zoy.org/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(<ID>){
  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));


[-- Attachment #3: Type: text/plain, Size: 3 bytes --]


  

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-02-06 23:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-03 13:39 hack to retag a directory david
2009-12-03 19:26 ` david
2010-02-06  1:41   ` Carl Worth
2010-02-06 23:38     ` David Bremner
2010-02-06 23:59       ` martin f krafft

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).