ninrename
posted January11th, 2007 @ 00:18:46
tags:
development
,
games
,
linux
,
python
comments: 0
Just "finished" hacking together some code that started out as a small desire and has ended up an obsession of sorts. Initially, it was just going to be a smart, specialized file renamer. It has ballooned into a poorly written (but fairly solid) beast of a program with crc checking and unrar/zipfile support. When I say it's poorly written, I mean it's not beautiful like my xdccq module is, for instance. It isn't elegant in the least, does things in a way that is acknowledged as poor design decisions, and the main dispatch is a giant ugly conditional mess. But it works pretty well!
The script takes a ClrMamePro formatted rom release list and a local directory as arguments (with various options available), and can perform hash checks and smart renames of files to 'Official' names. You can find such formatted files at advanscene or pocketheaven. There is a special switch on the program that removes several hardware dumps from the pocketheaven list and outputs a 'clean' list which will match up more with the 'scene' numbering system.
There are quite a lot of programs like this available, but this one is command line, written in python, runs in linux, suited to logging, and written by me. You'll need the rarfile module written by Mario Kreen (thanks Cheeseshop!) if you want rar support (or if you want the program not to throw an exception when it doesn't find it). You'll also need cksum.py in the same directory because I am feeling quite lazy this time around. Even though there's nothing in there (even rarfile has a windows equivalent wich wraps UnRAR.dll or something) that is overly platform specific, because 1. this was a oneoff, 2. I run linux, and 3. I don't like Windows anyway, this won't run in Windows and I have ZERO impetus to change that.
Anyway, the help screen (options):
usage: gbaname.py [options] datfile [romdir]
options:
--version show program's version number and exit
-h, --help show this help message and exit
-c, --crc perform crc checking
-r, --rename perform rom renaming
-p, --pretend do not rename but display actions
-m, --missing show missing roms
-g RANGE, --range=RANGE
perform only over range (#-#)
-n, --nds-clean remove MAX Media Launcher, reorder, etc
-v, --verbose ever present verbose mode
Features:
- looks up files by release number and correlates them to your release info dat
- performs actions over a range of release numbers (rather than all files)
- renames files according to the dat
-
performs crc hash checks on files (.gba, .nds, .zip, and .rar supported)
- if a file fails a hash check and renaming is active, (!) is recorded in the filename
- clean pocketheaven NDS lists (this feature is pretty dangerous; it will mangle non-PH lists)
- show a log of 'missing' roms (missing from the current list of known dumps)
If you still want it (it is pretty to look at at least), you can download it. There are some useful recipe's in there, even for what's basically an elaborate one-off... too useful not to throw up on the internet.
There are tons more features I can think of that I'm in no hurry to implement, including a feature that was initially planned which is doing fuzzy string comparisson (using normalized levenshtein distances) to figure out what file is what rather than release numbers (which, afterall, can be wrong). This would provide a great deal of safety to the whole thing (although if your archive's crc files match up it's pretty straightforward to modify this script and fix the names). I won't make any ridiculous patronizing remarks about how this is for your own backups etc and so forth, since most people who are looking for something like this do not own 2600 gba games and fret unduly over their private dump collection. I will add (interestingly) that, using my own linker (which dumps as well), I was able to dump a bad image of my broken Metal Slug Advanced cart and good (matching the 'release' crc!) images of Final Fantasy IV and Megaman Zero 2. So.. hey!