@@ -0,0 +1,1890 @@
+import os%0Aimport subprocess%0A%0Aclass MoveFiles:%0A%0A    def __init__(self, rule, copy):%0A        %22%22%22%0A        Move audiofiles to the appropriate destination directories,%0A        as determined by the 'rule' function passed to rule%0A        :param rule:%0A        :return:%0A        %22%22%22%0A        self.rule = rule%0A        self.copy = copy%0A%0A    def move_files(self, files):%0A        %22%22%22%0A        Iterate over the elements of a ProcessDirectory object, and move them to the correct directory,%0A        using python subprocess%0A%0A        :param files:%0A        :return:%0A        %22%22%22%0A        args = list()%0A        files.first()%0A        if self.copy:%0A            args.append(%22copy%22)%0A        else:%0A            args.append(%22move%22)%0A%0A        for f in files:%0A%0A%0A                self.model.first()%0A%0A        if self.copy_dir:%0A            move = shutil.copy%0A        else:%0A            move = shutil.move%0A%0A        while self.model.has_next():%0A            release = self.model.next()%0A%0A            # get path to has-mbid and no-mbid folders once per release%0A            release_path = os.path.split(release%5B0%5D.file_name)%5B0%5D%0A            picard = release%5B0%5D.picard%0A            mb = release%5B0%5D.mb%0A%0A            if not os.path.exists(picard):%0A                os.mkdir(picard)%0A            if not os.path.exists(mb):%0A                os.mkdir(mb)%0A%0A            for track in release:%0A                # move to correct folder%0A                move(track.file_name, track.dest_dir)%0A                print(%22moving %22 + ascii(track.file_name) + %22 to %22 + ascii(track.dest_dir))%0A%0A%0A            try:%0A                os.rmdir(picard)%0A            except OSError as e:%0A                pass%0A%0A            try:%0A                os.rmdir(mb)%0A            except OSError as e:%0A                pass%0A%0A            try:%0A                os.rmdir(release_path)%0A            except OSError as e:%0A                # release directory is not empty%0A                continue%0A

Add script to move files (move this out of MetaControl)