Created
September 29, 2021 13:04
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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