Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ZachSaucier/f51e608ac75e8ed6e96cd54a9ec103b0 to your computer and use it in GitHub Desktop.
Save ZachSaucier/f51e608ac75e8ed6e96cd54a9ec103b0 to your computer and use it in GitHub Desktop.

Revisions

  1. ZachSaucier revised this gist Jan 3, 2021. 1 changed file with 8 additions and 3 deletions.
    11 changes: 8 additions & 3 deletions Tag and rename MP3 files with "Artist - Title" formatting.py
    Original file line number Diff line number Diff line change
    @@ -5,11 +5,16 @@
    filename = os.path.basename(file)
    if " - " in filename:
    artist, track = filename.split(' - ')
    if "".__eq__(track):
    track = artist
    artist = ""

    audiofile = eyed3.load("./" + filename)
    audiofile.initTag()
    audiofile.tag.artist = unicode(artist)
    audiofile.tag.title = unicode(track.split('.mp3')[0])

    if not "".__eq__(artist):
    audiofile.tag.artist = artist
    audiofile.tag.title = track.split('.mp3')[0]
    audiofile.tag.save()

    os.rename(filename, track)
    os.rename(filename, track)
  2. ZachSaucier revised this gist Jan 27, 2020. 1 changed file with 1 addition and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@

    audiofile = eyed3.load("./" + filename)
    audiofile.initTag()
    audiofile.tag.artist = unicode("utf-8")
    audiofile.tag.artist = unicode(artist)
    audiofile.tag.title = unicode(track.split('.mp3')[0])
    audiofile.tag.save()

  3. ZachSaucier revised this gist Jan 27, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions Tag and rename MP3 files with "Artist - Title" formatting.py
    Original file line number Diff line number Diff line change
    @@ -8,8 +8,8 @@

    audiofile = eyed3.load("./" + filename)
    audiofile.initTag()
    audiofile.tag.artist = artist
    audiofile.tag.title = track.split('.mp3')[0]
    audiofile.tag.artist = unicode("utf-8")
    audiofile.tag.title = unicode(track.split('.mp3')[0])
    audiofile.tag.save()

    os.rename(filename, track)
  4. ZachSaucier revised this gist Nov 16, 2019. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions Tag and rename MP3 files with "Artist - Title" formatting.py
    Original file line number Diff line number Diff line change
    @@ -4,13 +4,12 @@
    for file in glob.glob("*.mp3"):
    filename = os.path.basename(file)
    if " - " in filename:
    artist = filename.split(' - ')[0]
    track = filename.split(' - ')[1].split('.mp3')[0]
    artist, track = filename.split(' - ')

    audiofile = eyed3.load("./" + filename)
    audiofile.initTag()
    audiofile.tag.artist = artist
    audiofile.tag.title = track
    audiofile.tag.title = track.split('.mp3')[0]
    audiofile.tag.save()

    os.rename(filename, track + '.mp3')
    os.rename(filename, track)
  5. ZachSaucier created this gist Nov 16, 2019.
    16 changes: 16 additions & 0 deletions Tag and rename MP3 files with "Artist - Title" formatting.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    import os, glob, eyed3

    os.chdir("./")
    for file in glob.glob("*.mp3"):
    filename = os.path.basename(file)
    if " - " in filename:
    artist = filename.split(' - ')[0]
    track = filename.split(' - ')[1].split('.mp3')[0]

    audiofile = eyed3.load("./" + filename)
    audiofile.initTag()
    audiofile.tag.artist = artist
    audiofile.tag.title = track
    audiofile.tag.save()

    os.rename(filename, track + '.mp3')