mirror of
https://github.com/hanxi/xiaomusic.git
synced 2026-03-15 08:13:16 +08:00
fix: 修复歌曲批量重命名的问题
This commit is contained in:
@@ -1,8 +1,29 @@
|
||||
from xiaomusic.utils import (
|
||||
remove_common_prefix,
|
||||
)
|
||||
import re
|
||||
|
||||
|
||||
def removepre(filename):
|
||||
match = re.search(r"^(\d+)\s+\d*(.+?)\.(.*$)", filename.strip())
|
||||
new_filename = filename
|
||||
if match:
|
||||
num = match.group(1)
|
||||
name = match.group(2).replace(".", " ").strip()
|
||||
suffix = match.group(3)
|
||||
# print(name)
|
||||
# print(num)
|
||||
# print(suffix)
|
||||
new_filename = f"{num}.{name}.{suffix}"
|
||||
|
||||
print(filename, "=>", new_filename)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
remove_common_prefix(
|
||||
"./tmp/【无损音质】2024年9月酷狗热歌榜TOP100合集(只选热歌最高的)首首王炸,分P合集!"
|
||||
)
|
||||
removepre(" 17 《白色风车》.mp3")
|
||||
removepre(" 17 《白色风车》.mp3")
|
||||
removepre(" 17 17 《白色风车》.mp3")
|
||||
removepre(" 17 17 《白色风车》.mp3")
|
||||
|
||||
removepre(" 18 风车.mp3")
|
||||
removepre(" 18 色风车.mp3")
|
||||
removepre(" 18 18 你好.mp3")
|
||||
removepre(" 18 18 我好.mp3")
|
||||
removepre("09 009. 梁静茹-亲亲.mp3")
|
||||
|
||||
Reference in New Issue
Block a user