fork(1) download
  1. import re
  2. s=r"""DOTA:龍之血_S01E01_雷霆的話.mp4
  3. DOTA:龍之血_S01E02_一無所有的公主.mp4
  4. DOTA:龍之血_S01E03_無處之地.mp4
  5. DOTA:龍之血_S01E04_本書結尾的怪獸.mp4
  6. DOTA:龍之血_S01E05_火誡.mp4
  7. DOTA:龍之血_S01E06_騎士、死亡和魔鬼.mp4
  8. DOTA:龍之血_S01E07_說出來.mp4
  9. DOTA:龍之血_S01E08_對弈.mp4"""
  10.  
  11. ms = r"(?P<t>.+?)_S(?P<s>\d+)E(?P<e>\d+)_(?P<sub>.*?)\s?(?P<f>(?:.(?!\.))+$)"
  12. a = [_ for _ in list(filter(None, s.split('\n')))]
  13. b = ['EP{} {}{}'.format(m.group('e').zfill(2), m.group('sub'), m.group('f')).strip().upper() for m in [re.match(ms,_) for _ in a]]
  14.  
  15. for _ in zip(a, b):
  16. print('ren "{}" "{}"'.format(_[0],_[1]))
  17.  
  18.  
Success #stdin #stdout 0.03s 9416KB
stdin
Standard input is empty
stdout
ren "DOTA:龍之血_S01E01_雷霆的話.mp4" "EP01 雷霆的話.MP4"
ren "DOTA:龍之血_S01E02_一無所有的公主.mp4" "EP02 一無所有的公主.MP4"
ren "DOTA:龍之血_S01E03_無處之地.mp4" "EP03 無處之地.MP4"
ren "DOTA:龍之血_S01E04_本書結尾的怪獸.mp4" "EP04 本書結尾的怪獸.MP4"
ren "DOTA:龍之血_S01E05_火誡.mp4" "EP05 火誡.MP4"
ren "DOTA:龍之血_S01E06_騎士、死亡和魔鬼.mp4" "EP06 騎士、死亡和魔鬼.MP4"
ren "DOTA:龍之血_S01E07_說出來.mp4" "EP07 說出來.MP4"
ren "DOTA:龍之血_S01E08_對弈.mp4" "EP08 對弈.MP4"