@@ -0,0 +1,1901 @@
+#!/usr/bin/env python%0A# -*- coding: utf-8 -*-%0A%22%22%22Find name patterns in a tree%22%22%22%0A%0Aimport KmdCmd%0Aimport KmdFiles%0A%0Aimport os, sys, re, time%0Aimport logging%0A%0Aclass KmdFindPatterns(KmdCmd.KmdCommand):%0A    def extendParser(self):%0A        super(KmdFindPatterns, self).extendParser()%0A        #Extend parser%0A        self.parser.add_argument('srctree', metavar='%3C/path/to/srctree%3E', nargs=1, help='Root of a src tree')%0A%0A    def run(self):%0A     %0A        patterns = %7B%7D #store patterns and matching file names%0A        knownpatterns = %5B%0A            r'%5E(%5Cd%5Cd%5Cd%5Cd)(%5Cd%5Cd)(%5Cd%5Cd)_.*?$',%0A            %5D%0A                %0A        for root, dirs, files in os.walk(self.args.srctree%5B0%5D):%0A            for name in files:%0A                #for each file in the folder%0A                p = os.path.join(root, name)%0A                m = None%0A                for k in knownpatterns :%0A                    m = re.compile(k, re.I).match(name)%0A                    if m :%0A                      break%0A                if not m :%0A                    logging.debug(%22not matching file : %25s%22, p)    %0A                    continue%0A                logging.debug(%22Groups %25s%22, m.groups())%0A                logging.debug(%22Matching file : %25s%22, p)%0A                olddt = KmdFiles.get_modification_date(p)%0A                logging.debug(%22OLDDT : %25s%22, olddt)%0A                newdt = olddt.replace(%0A                  year = int(m.groups()%5B0%5D),%0A                  month = int(m.groups()%5B1%5D),%0A                  day = int(m.groups()%5B2%5D)%0A                  )%0A                logging.debug(%22NEWDT : %25s%22, newdt)%0A                ts = time.mktime(newdt.timetuple())%0A                %0A                logging.debug(%22TS : %25s%22, ts)%0A                logging.info(%22Changing time for %25s to %25s%22, p, ts)%0A                if self.args.doit :%0A                      KmdFiles.set_modification_date(p, ts)%0A%0Aif __name__ == %22__main__%22:%0A    cmd = KmdFindPatterns(__doc__)%0A    cmd.run()%0A%0A

Set time according to date in filename