Skip to content

Instantly share code, notes, and snippets.

@maximko
Created September 29, 2021 13:04
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 maximko/52081c3d027b325fbbd2f3b5258a4e58 to your computer and use it in GitHub Desktop.
Save maximko/52081c3d027b325fbbd2f3b5258a4e58 to your computer and use it in GitHub Desktop.
Convert Rekordbox 6 XML to RB5 XML so you can import it to Rekordbox version 5
#!/usr/local/bin/python3
import xml.etree.ElementTree as ET
import sys
import os.path
next_TrackID = 1901
old_new = {}
filename = sys.argv[1]
if not os.path.isfile(filename):
print("No such file %s" % filename)
sys.exit(1)
# XML init
rekordbox_xml = ET.parse(filename)
root = rekordbox_xml.getroot()
for track in root.findall("./COLLECTION/TRACK"):
old_new[track.attrib['TrackID']] = str(next_TrackID)
track.attrib['TrackID'] = str(next_TrackID)
next_TrackID += 1
for track in root.findall("./PLAYLISTS//TRACK"):
old_key = track.attrib['Key']
track.attrib['Key'] = old_new[old_key]
with open(filename + '.rb5.xml', "wb") as f:
f.write(ET.tostring(root))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment