Skip to content

Instantly share code, notes, and snippets.

@saxbophone
Created April 30, 2017 22:53
Show Gist options
  • Select an option

  • Save saxbophone/9ec95eee76637fa03a08f86276fbd343 to your computer and use it in GitHub Desktop.

Select an option

Save saxbophone/9ec95eee76637fa03a08f86276fbd343 to your computer and use it in GitHub Desktop.
Bandcamp is great but the naming format they use for the downloaded tracks doesn't suit my system, so this script converts them!
import os
def fix_track_names(artist, album):
"""
Given an artist name and album name, renames all the tracks in the current
directory from the format that Bandcamp names them to the format that I
want them (<track number> - <track name>)
"""
for track in os.listdir('.'):
# skip the cover artwork
if track == 'cover.jpg':
continue
os.rename(
track,
' - '.join(
track.split(
'{} - {} - '.format(artist, album)
)[1].split(' ', 1)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment