Skip to content

Instantly share code, notes, and snippets.

@maximko
Created September 29, 2021 13:04
Show Gist options
  • 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))
@kidhup
Copy link

kidhup commented Mar 15, 2025

Hi, when i run this command in phyton i get this error:

 line 10, in <module>
    filename = sys.argv[1]
               ~~~~~~~~^^^
IndexError: list index out of range

Not sure how to use this script other than just run it.
Please let me know how to make this work. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment