fork(3) download
  1. import re
  2. s=r"""B:彼之初_S02E01_第 1 集.mp4
  3. B:彼之初_S02E02_第 2 集.mp4
  4. B:彼之初_S02E03_第 3 集.mp4
  5. B:彼之初_S02E04_第 4 集.mp4
  6. B:彼之初_S02E05_第 5 集.mp4
  7. B:彼之初_S02E06_第 6 集.mp4"""
  8.  
  9. ms = r"(?P<t>.+?)_S(?P<s>\d+)E(?P<e>\d+)_(?P<sub>.*?)\s?(?P<f>(?:.(?!\.))+$)"
  10. a = [_ for _ in list(filter(None, s.split('\n')))]
  11. 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]]
  12.  
  13. for _ in zip(a, b):
  14. print('ren "{}" "{}"'.format(_[0],_[1]))
  15.  
  16.  
Success #stdin #stdout 0.03s 9496KB
stdin
Standard input is empty
stdout
ren "B:彼之初_S02E01_第 1 集.mp4" "EP01 第 1 集.MP4"
ren "B:彼之初_S02E02_第 2 集.mp4" "EP02 第 2 集.MP4"
ren "B:彼之初_S02E03_第 3 集.mp4" "EP03 第 3 集.MP4"
ren "B:彼之初_S02E04_第 4 集.mp4" "EP04 第 4 集.MP4"
ren "B:彼之初_S02E05_第 5 集.mp4" "EP05 第 5 集.MP4"
ren "B:彼之初_S02E06_第 6 集.mp4" "EP06 第 6 集.MP4"