Created
November 1, 2019 22:45
-
-
Save lingmujianshi/88d0ad6d0ec20a74e48fcdf51947b45a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# coding: utf-8 | |
import os | |
from mutagen.easyid3 import EasyID3 | |
import jaconv | |
# フォルダ名(スクリプトがある場所に処理するフォルダを作成した。) | |
dirname=u'./瞬間英作文シャッフル2' | |
files = os.listdir(dirname) | |
# フォルダ内のファイルを読み込む | |
for f in files: | |
# MP3ファイル以外は処理しない。 | |
if(f[-4:] != '.mp3'): | |
continue | |
# mp3ファイルの絶対パス | |
path = dirname +'/' + f | |
# mp3ファイルからタグオブジェクトを取り出す。 | |
tags = EasyID3(path) | |
# 現在の曲名を取得 | |
currentTag=tags['title'] | |
# 全角を半角に変換し、"Part"という文字列を削除 | |
newTag = jaconv.z2h(currentTag[0],ignore='',kana=True,digit=True, ascii=True).replace('Part','') | |
# タイトルに書き込んでセーブ | |
tags['title']=newTag | |
tags.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment