Пример #1
0
 def rename_dir(self, directory, pattern, dry_run):
   valid_tags = self.files_with_valid_tags(directory)
   for (file, id3) in valid_tags:
     values = dict()
     values["TALB"] = Check.get_value(id3, "TALB", "Unknown")
     values["TRCK"] = Renamer.first_part(id3, "TRCK")
     values["TPOS"] = Renamer.first_part(id3, "TPOS")
     values["TIT2"] = Check.get_value(id3, "TIT2", "Unknown")
     values["TPE1"] = Check.get_value(id3, "TPE1", "Unknown")
     name = pattern % values
     name = re.sub('[/:]+', '', name)
     name = os.path.join(directory, name)
     print u"renaming file %r to %r" % (file, name)
     if not dry_run:
       os.rename(file, name)
Пример #2
0
 def first_part(id3, frame):
   value = Check.get_value(id3, frame, "0")
   return int(value.split("/")[0])