def rename_file(entry, pdf, bib, dry_run):
if entry['author']:
authors = entry['author'].split(',')
if len(authors) <= 3:
author = ', '.join(authors[:-1])
else:
author = authors[0] + ' et al.'
if author and 'year' in entry and 'title' in entry:
newname = author + ' - ' + '{}'.format(entry['year']) + ' - ' + algo.tex_to_unicode(algo.title_case(entry['title'])).replace("/", " ") + '.pdf'
if os.path.exists(pdf):
shutil.copy2(pdf, os.path.expanduser("~") + papers_path + newname)
entry.set_tag('file', ':' + pdf + ':PDF' )
if not dry_run:
shutil.move(pdf, os.path.expanduser("~") + '/.local/share/Trash/files/')
return True
return False
评论列表
文章目录