Jump to content
LaunchBox Community Forums

Script to create RocketLauncher game data ini files from LaunchBox xml's

Recommended Posts

This is a Python2.7 script to generate RocketLauncher game data ini files from the LaunchBox xml files so that the info displayed in RL's Pause screen is the same as what is in LB. If populated, it will use the 'Title', 'Publisher', 'Developer', 'ReleaseDate', 'Genre', 'StarRating', 'PlayMode', 'Rating', 'WikipediaURL', 'Notes' fields from the LB xml and will skip games with no data. It creates a backup of your existing RL ini files in the RL game data ini folder. RL will overwrite these files on udating, so you will need to run the script after that. Not sure if its possible to work around this.

You need to update the two variables to point to the folders that contain the LB and RL data files (beware of the forward slashes).


# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from __future__ import print_function
from itertools import izip
from HTMLParser import HTMLParser
import os
import shutil
import re
import sys
import xml.etree.ElementTree as ET

	txt_encode = sys.getfilesystemencoding()
	txt_encode = 'utf-8'

lb_dir = 'd:/emulation/LaunchBox/Data/Platforms'
rl_dir = 'c:/emulation/RocketLauncher/Data/Game Info'

rl_dir_backup = os.path.join(rl_dir, 'backup')
for system in os.listdir(lb_dir):
	if system.endswith(".xml"):
		system_name = system[:-4]
		xml_lb = os.path.join(lb_dir, system)
		ini_rl = os.path.join(rl_dir, system_name+'.ini')
		h = HTMLParser()
		if os.path.exists(ini_rl):
			if not os.path.exists(rl_dir_backup):
			if os.path.exists(os.path.join(rl_dir_backup, system_name+'.ini')):
				if os.path.exists(os.path.join(rl_dir_backup, system_name+'.ini.old')):
					os.remove(os.path.join(rl_dir_backup, system_name+'.ini.old'))
				shutil.move(os.path.join(rl_dir_backup, system_name+'.ini'), os.path.join(rl_dir_backup, system_name+'.ini.old'))
			shutil.move(ini_rl, rl_dir_backup)
		tree = ET.parse(xml_lb)
		root = tree.getroot()
		lb_label = ['Title', 'Publisher', 'Developer', 'ReleaseDate', 'Genre', 'StarRating', 'PlayMode', 'Rating', 'WikipediaURL', 'Notes']
		rl_label = ['Title', 'Publisher', 'Developer', 'Released', 'Genre', 'Score', 'Players', 'Rating', 'Url', 'Description']
		with open(ini_rl, 'w') as f:
			for game in root.findall('Game'):
				info_game = ''
				for lbl,rll in izip(lb_label, rl_label):
					if game.find(lbl) != None and game.find(lbl).text:
						if rll == 'Title':
							info = '[' + h.unescape(game.find(lbl).text) + ']'
							info = info.replace('\r', ' ').replace('\n', ' ') + "\n"
							info = re.sub(' +', ' ', info)
							info_game = info_game + info
						elif rll == 'Released':
							info = h.unescape(game.find(lbl).text)[:4]
							info = rll + '=' + info + "\n"
							info_game = info_game + info
							info = rll + '=' + h.unescape(game.find(lbl).text)
							info = info.replace('\r', ' ').replace('\n', ' ') + "\n"
							info = re.sub(' +', ' ', info)
							info_game = info_game + info
				s = ('Publisher', 'Developer', 'Released', 'Genre', 'Players', 'Rating', 'Url', 'Description')
				if any(x in info_game.encode("utf-8") for x in s):


Edited by teeedubb
  • Like 3
Link to comment
Share on other sites

Just tested this out and it works great. Much better implementation than the default way RocketLauncher creates its game data inis from launchbox. Fixed a couple issues for me, mainly fade screens for mame games now show the actual name of the game, not the zip name. Thanks!

  • Like 1
Link to comment
Share on other sites

Save the script above as lb-rl-game-data.py somewhere on your PC, and update the lines beginning with 'lb_dir =' and 'rb_dir =' to point to your launchbox and rocketlauncher game data directories ( a dir full of xml or ini files named the same as platforms in either program). Watch the forward slashes.

Download and install Python 2.7. After Python is installed you should be able to simply double click on the lb-rl-game-data.py file, if not, run the following in a cmd prompt (win+r > cmd > enter)

"c:\path\to\python.exe" "c:\path\to\lb-rl-game-data.py"

Edited by teeedubb
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...