Skip to content

Instantly share code, notes, and snippets.

@lingmujianshi
Created November 1, 2019 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lingmujianshi/88d0ad6d0ec20a74e48fcdf51947b45a to your computer and use it in GitHub Desktop.
Save lingmujianshi/88d0ad6d0ec20a74e48fcdf51947b45a to your computer and use it in GitHub Desktop.
#! /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