Initial commit
This commit is contained in:
43
mp3/rename_mp3.py
Normal file
43
mp3/rename_mp3.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import re, os
|
||||
import unicodedata
|
||||
|
||||
from xml.dom.minidom import Element
|
||||
|
||||
from pydub.effects import normalize
|
||||
|
||||
#Lese eine Datei
|
||||
with open('Uebersicht_der_Wörter_20250421.txt', 'r', encoding='utf-8') as input_file:
|
||||
for line in input_file:
|
||||
tmp = line.split('\t')[2]
|
||||
nr = line.split('\t')[0]
|
||||
|
||||
|
||||
# Löschen aller Zeichen die nicht Buchstaben oder Unterstrich sind
|
||||
tmp = re.sub(r'[^a-zA-ZäöüÜÄÖåÅé -]', '', tmp)
|
||||
# Löschen der Leezeichen am Ende
|
||||
tmp = tmp.strip()
|
||||
nr = nr.strip()
|
||||
|
||||
# Umwandeln von Leerzeichen in Unterstrich
|
||||
tmp = tmp.replace(" ", "_")
|
||||
#print(tmp)
|
||||
|
||||
# Suche im Ordner im Pfad der Python-Datei eine Datei die den Namen tmp hat
|
||||
|
||||
for root, dirs, files in os.walk("."):
|
||||
for file in files:
|
||||
if file.endswith(".mp3"):
|
||||
|
||||
#Suche den Dateinamen ohne die Erweiterung
|
||||
file = unicodedata.normalize('NFC', os.path.splitext(file)[0])
|
||||
|
||||
#print ("File: "+ file.lower())
|
||||
if file.lower() == tmp.lower():
|
||||
#der Vergleich funktioniert nicht 'ägaren' und 'ägaren' sind nicht gleich
|
||||
#Kann man String noch anders vergleichen?
|
||||
|
||||
#print("Gefunden: "+nr +"-" +tmp.lower()+".mp3")
|
||||
#print("Neu: "+nr +"-" +tmp.lower()+".mp3")
|
||||
|
||||
os.rename(file+".mp3", nr+ "-" +tmp.lower()+".mp3") # Umbenenne die Datei
|
||||
|
||||
Reference in New Issue
Block a user