Created
June 3, 2011 05:16
-
-
Save maddox/1005911 to your computer and use it in GitHub Desktop.
Convert a Maximus Arcade game list to a MameUI game list
This file contains hidden or 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
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