Skip to content

Instantly share code, notes, and snippets.

@maddox
Created June 3, 2011 05:16
Show Gist options
  • Save maddox/1005911 to your computer and use it in GitHub Desktop.
Save maddox/1005911 to your computer and use it in GitHub Desktop.
Convert a Maximus Arcade game list to a MameUI game list
require 'rubygems'
require 'json'
require 'open-uri'
filename = "MAME_Favorites.txt"
list_text = open(filename).read
# replace brackets
list_text.gsub!('[', '{')
list_text.gsub!(']', '}')
#replace key format
list_text.gsub!(/#(\w+):/, '"\1":')
# replace stupid win32 slashes
list_text.gsub!('\\', '-')
# prepare head of favorites file
out = "[FOLDER_SETTINGS]
RootFolderIcon cust1
SubFolderIcon cust2
[ROOT_FOLDER]
"
# add roms to list
JSON::parse(list_text).each_value do |rom|
out << %{#{rom['name']}\n}
end
# write the file out
File.open('favorites.ini', 'w+').write(out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment