Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*- ### <<< required @ first line
- # rem_trk99.py + proper titlecasing
- import os, re
- def solve(s):
- name, ext = os.path.splitext(s)
- name = name.replace('_',' ')
- if ' - ' not in name: name = name.replace('-',' - ')
- v='[\[|\(|\{|+|#]?\d{1,2}[\.|:|\]|\)|\}| -]+'
- name = re.sub('^.?'+v+'[ ]?', '', name)
- name = re.sub(' - '+v, ' - ', name)
- ### To have both [ A.B.C. ] and [ It'll ]
- return re.sub(r"[A-Za-z]+('[A-Za-z]+)?",
- lambda mo: mo.group(0)[0].upper() +
- mo.group(0)[1:].lower(), name)
- print solve("DJ 99 - It'll be The Music_ Ft_ The A.B.C. and Artiste.mp3")
- print solve("05-dj_99-it'll_be_the_music-remix.mp3")
- print solve("05 - dj 99 - it'll be the music - remix.mp3")
- print solve("#5 - dj 99 - it'll be the music - remix.mp3")
- print solve("5.) dj 99 - it'll be the music - remix.mp3")
- print solve(" [5] dj 99 - it'll be the music - remix.mp3")
- print solve("{5} dj 99 - it'll be the music - remix.mp3")
- print solve("[05] dj 99 - it'll be the music - remix.mp3")
- print solve("05: dj 99 - it'll be the music - remix.mp3")
- print solve("100 - dj 99 - it'll be the music - remix.mp3")
- print solve("dj 99 - 05 - it'll be the music - remix.mp3")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement