""" The files must be in the form: paper title - [journal or conference] year [- author1 author2].pdf (terms in [] are optional) DO NOT use space in the name of an author """ if __name__ == '__main__': if len(sys.argv) > 1: mainDir = os.path.abspath(sys.argv[1]) else: mainDir = os.path.abspath(os.path.curdir) l = comicSort.dirExplore(mainDir, extension='.pdf') for paper in l: name, ext = os.path.splitext(paper.split('/')[-1]) tmp = name.split('-') title = tmp[0] for i in tmp[1].split(' '): if i.isdigit(): year = i #verify year if not year.isdigit(): continue #lloking for author author = '' if len(tmp) == 3: author = tmp[-1]
self.y = year self.m = month-1 def __str__(self): s = str(self.y)+'-'+str(self.m+1).zfill(2) return s def add(self, i): self.m += i%12 self.y += i/12 if __name__=="__main__": directory = '/media/portaz/17E771D5010CDC52/Perso/Comics/Captain America v3 1998-2002' exportName = 'Captain America v3' beginDate = date(1998,01) nbStart = 1 nbEnd = 33 comicList = comicSort.dirExplore(directory, extension='.cbr') comicList += comicSort.dirExplore(directory, extension='.cbz') for comic in comicList: name, ext = os.path.splitext(comic.split('/')[-1]) number = extractNumber(name, '_') if number == -1: print("Cannot find the number of the comic:", comic) continue else: if number >= nbStart and number <= nbEnd: d = date(1998,01) d.add(number-1) os.rename(comic, directory+'/'+str(d)+' '+exportName+' '+str(number).zfill(3)+ext)