PDA

View Full Version : ReMAMEr - renaming utility



blur
09-24-2010, 03:09 PM
Somebody here on forum asked that it would be good to have utility to rename all mame and hyperspin files when new version of MAME rename set dat file comes out.

Mame rename set can be found here http://www.progettosnaps.net/renSET/pS_renameSET.txt

It is a file with lines like this:
$0.139u2 <-- MAME version
fatfursa > fatfurspa <-- file fatfursa is renamed to fatfurspa


So here it is, MAME renaming utility - ReMAMEr

It is a unix shell script zipped together with all utils needed to run it.
Script parses mame input file and renames all of your:

roms
wheel images
themes
videos, screenshots
cabinet images, flyers, save states, ini files, marquees, hi scores, nv rams, ...


Input file is parsed from the end to the beginning because latest version is on top of the file.


How to run it?

Download remamer.zip from http://uploading.com/files/16e79473/ReMAMEr%2B3.0.zip/ and extract it somewhere on your disk.
Open remamer.sh with notepad or wordpad and:

put your mame file name in lines like this:

######################################
# WRITE YOUR MAME INPUT FILE NAME HERE
export input_file="pS_renameSET.txt"
######################################


put all your directories that you want checked, together with file extensions in lines like this:


################################################## ########################
# CONFIGURE YOUR PATHS AND DOUBLE CLICK ON RUN_ME.BAT TO RUN THE SCRIPT
################################################## ########################
remame "D:/Games/Emulators/MAME/roms" zip
remame "D:\Games\Emulators\HyperSpin\Media\MAME\Video" flv
remame "D:\Games\Emulators\HyperSpin\Media\MAME\Video" png
remame "D:\Games\Emulators\HyperSpin\Media\MAME\Themes" zip
remame "D:\Games\Emulators\HyperSpin\Media\MAME\Images\Whe el" png
remame "D:\Games\Emulators\HyperSpin\Media\MAME\Images\Art work1" png
remame "D:\Games\Emulators\HyperSpin\Media\MAME\Images\Art work2" png
remame "D:\Games\Emulators\HyperSpin\Media\MAME\Images\Art work3" png
remame "D:\Games\Emulators\HyperSpin\Media\MAME\Images\Art work4" png
remame "D:\Games\Emulators\HyperSpin\Media\MAME\Images\Bac kground" png
remame "D:/Games/Emulators/MAME/artwork" zip
remame "D:/Games/Emulators/MAME/cabinets" png
remame "D:/Games/Emulators/MAME/cabinets" jpg
remame "D:/Games/Emulators/MAME/cfg" cfg
remame "D:/Games/Emulators/MAME/cpanel" png
remame "D:/Games/Emulators/MAME/cpanel" jpg
remame "D:/Games/Emulators/MAME/flyers" png
remame "D:/Games/Emulators/MAME/flyers" jpg
remame "D:/Games/Emulators/MAME/hi" hi
remame "D:/Games/Emulators/MAME/icons" ico
remame "D:/Games/Emulators/MAME/ini" ini
remame "D:/Games/Emulators/MAME/marquees" png
remame "D:/Games/Emulators/MAME/marquees" jpg
remame "D:/Games/Emulators/MAME/nvram" nv
remame "D:/Games/Emulators/MAME/samples" zip
remame "D:/Games/Emulators/MAME/snap" png
remame "D:/Games/Emulators/MAME/snap" jpg
remame "D:/Games/Emulators/MAME/sta"
remame "D:/Games/Emulators/MAME/titles" png
remame "D:/Games/Emulators/MAME/titles" jpg


Save remamer.sh

Double click on RUN_ME.BAT and script will start.

Check for error messages on the screen and check if your files are renamed.

Report any errors that you find.

Best regards.

djvj
09-24-2010, 07:54 PM
Did you make this? If so, very cool.

This should be moved to http://www.hyperspin-fe.com/forum/forumdisplay.php?f=39

blur
09-25-2010, 12:09 AM
Yup, i made it, as you can see from lousy english :)))

Similar scripts can be made quite easy for various purposes.

blur
09-25-2010, 04:35 PM
Found some errors in script.
Errors are corrected and new zip file is uploaded, link is in first post.
Also added a lots of checks, check if mame input file exists, check if parsing directories exist, and so on.
Every directory that doesn't exist is skipped.
Added a message whenever rename actually occurs so you will see from output what is renamed, and what is not.

blur
09-26-2010, 05:37 AM
Here is output from the script, before setting paths:


-------------------------------------------------
------------------ ReMAMEr 2.0 ------------------
------------ MAME RENAMESET.DAT parser ----------
-------------------------------------------------

Your MAME input file is pS_renameSET.txt
If you are not happy with that terminate with Control-C and edit remamer.sh script or press Enter to continue:

Directory D:/Games/Emulators/MAME/roms doesn't exist, skipping directory.
Directory D:/Games/Emulators/HyperSpin/Media/MAME/Video doesn't exist, skipping directory.
Directory D:/Games/Emulators/HyperSpin/Media/MAME/Video doesn't exist, skipping directory.
Directory D:/Games/Emulators/HyperSpin/Media/MAME/Themes doesn't exist, skipping directory.
Directory D:/Games/Emulators/HyperSpin/Media/MAME/Images/Wheel doesn't exist, skipping directory.
Directory D:/Games/Emulators/HyperSpin/Media/MAME/Images/Artwork1 doesn't exist, skipping directory.
Directory D:/Games/Emulators/HyperSpin/Media/MAME/Images/Artwork2 doesn't exist, skipping directory.
Directory D:/Games/Emulators/HyperSpin/Media/MAME/Images/Artwork3 doesn't exist, skipping directory.
Directory D:/Games/Emulators/HyperSpin/Media/MAME/Images/Artwork4 doesn't exist, skipping directory.
Directory D:/Games/Emulators/HyperSpin/Media/MAME/Images/Background doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/artwork doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/cabinets doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/cabinets doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/cfg doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/cpanel doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/cpanel doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/flyers doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/flyers doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/hi doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/icons doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/ini doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/inp doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/marquees doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/marquees doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/nvram doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/samples doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/snap doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/snap doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/sta doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/titles doesn't exist, skipping directory.
Directory D:/Games/Emulators/MAME/titles doesn't exist, skipping directory.

Script has finished, scroll back and check for errors, press Enter when finished.


And here is after setting some paths, and putting some files in them - aladbl and fatfursa:


-------------------------------------------------
------------------ ReMAMEr 2.0 ------------------
------------ MAME RENAMESET.DAT parser ----------
-------------------------------------------------

Your MAME input file is pS_renameSET.txt
If you are not happy with that terminate with Control-C and edit remamer.sh script or press Enter to continue:

Renaming files with extension zip in directory D:/Dean/Games/Emulatori/MAME/roms
Renaming files with extension zip in directory D:/Dean/Games/Emulatori/MAME/artwork
renaming fatfursa.zip to fatfurspa.zip
renaming aladbl.zip to aladmdb.zip
Renaming files with extension png in directory D:/Dean/Games/Emulatori/MAME/cabinets
renaming fatfursa.png to fatfurspa.png
renaming aladbl.png to aladmdb.png
Renaming files with extension png in directory D:/Dean/Games/Emulatori/MAME/cpanel
renaming fatfursa.png to fatfurspa.png
renaming aladbl.png to aladmdb.png
Renaming files with extension png in directory D:/Dean/Games/Emulatori/MAME/flyers
renaming fatfursa.png to fatfurspa.png
renaming aladbl.png to aladmdb.png
Renaming files with extension flv in directory D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Video
Renaming files with extension png in directory D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Video
renaming fatfursa.png to fatfurspa.png
renaming aladbl.png to aladmdb.png
Renaming files with extension zip in directory D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Themes
renaming fatfursa.zip to fatfurspa.zip
renaming aladbl.zip to aladmdb.zip
Renaming files with extension png in directory D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Images/Wheel
renaming fatfursa.png to fatfurspa.png
renaming aladbl.png to aladmdb.png
Renaming files with extension png in directory D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Images/Artwork1
Renaming files with extension png in directory D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Images/Artwork2
Renaming files with extension png in directory D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Images/Artwork3
Renaming files with extension png in directory D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Images/Artwork4
Directory D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Images/Background doesn't exist, skipping directory.

Script has finished, scroll back and check for errors, press Enter when finished.


As you can see few files are renamed in themes, videos, wheels and other folders.

There is still one directory that is written incorrectly - background - it misses s on the end, it should be backgrounds, but that's not important unless you have some backgrounds there.

blur
10-03-2010, 12:35 PM
New version 3.0 is out, download it from:

http://uploading.com/files/16e79473/ReMAMEr%2B3.0.zip/

Link in first post is also updated.

So what's new.

I did reverse input file scanning in first two versions, that means i would rename last files first, and then go to the top of the file.

That was because I saw in diff file that on top is version 139u3, then 139u2, u1 etc.

So to be chronological one has to go from the end.

But then I saw that in some versions you have renames like:
raiden2d > raiden2c
raiden2e > raiden2d
raiden2f > raiden2e
which means 2d file is now 2c, 2e is 2d, and 2f is 2e. All clear.
But if you rename files from the bottom up, 2f will rewrite 2e, and then 2d and then 2c.
So from 3 files you get one, so obviously bottom up was not a good way.

What about top to bottom?

While I thought about that I found lines like these:
ffightj1 > ffightj2
ffightj2 > ffightj1
or these:
forgottnu > forgottnua
forgottnua > forgottnu

Yup they are cyclic - two files are switched so no matter what way you go you will lose one. Or not? ... Surely something had to be done to the script.

So I introduced man in the middle - all files in one dir are renamed to middle names which are gamexyz following by row number (name had to be different from some game name) and then to final names in second pass. So don't be surprised when you see funny names on screen.

For people that will think, oh no, this script will mess my files and i won't see what it is doing, there is a preview, before renaming each dir all files that would be renamed are printed on screen and you can continue to rename them or type n to skip that dir or you can type Control-C and exit whole script.

Another new thing is listing of files while they are copied so you can see what is copied.

Another new thing is undo, there is script remamer.bat which renames files and remamer undo.bat which renames everything back.

Another new thing is script "wots missing.bat"
This script takes xml file as input and checks for files that belong to games in this file, so it searches videos, themes, wheels, whatever, and checks which files are missing.

You configure it same as remamer, by going to wots "missing.sh" and changing file locations.

There is also one last script (i promise it's last for today) "wots missing w clones.bat"
This one checks the same thing as previous one, game files for xml file, but since there is an option use parent themes and use parent videos in Hyperspin, every time the clone game is found that has no video - parent game video is checked.

With this I checked what videos am i missing from Lashek's mame greatest hits xml (I use it as main mame.xml), and first script gives me about 20-30 missing files, while other script gives me just one missing video - great!

Any way please download latest version and report what you think, bugs, ideas etc.

Did I say that scripts are very fast and parse thousands of files and directories in a blink of an eye.

And what's best - ones you configure directories you can run wots missing script many times just by double clicking the bat file - so you can easily use them to search and found what videos have names that don't match - just open explorer next to it, find the file that has different name but you see that it is it, only few letters missing and rename it.

it is good idea to enlarge buffer and screen size in comand prompt window so you don't miss part of text.

blur
10-04-2010, 02:44 AM
Here is an example of one rename session, you see output that you get in command window after double clicking remamer.bat:


-------------------------------------------------
------------------ ReMAMEr 3.0 ------------------
------------ MAME RENAMESET.DAT parser ----------
-------------------------------------------------

Your MAME input file is pS_renameSET.txt

Press Enter to continue or Control-C to exit

Directory D:/Torenti/roms doesn't exist, skipping directory.

Renaming flv files in D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Video
Searching...
No files found.

Renaming png files in D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Video
Searching...
D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Video/aladbl.png to aladmdb.png
D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Video/fatfursa.png to fatfurspa.png
Press Enter to rename, n to skip or Control-C to exit

D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Video/aladbl.png -> D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Video/gamexyz1.png
D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Video/fatfursa.png -> D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Video/gamexyz8.png
D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Video/gamexyz1.png -> D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Video/aladmdb.png
D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Video/gamexyz8.png -> D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Video/fatfurspa.png

Renaming zip files in D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Themes
Searching...
D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Themes/aladbl.zip to aladmdb.zip
D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Themes/fatfursa.zip to fatfurspa.zip
Press Enter to rename, n to skip or Control-C to exit
n
Skipping directory

Renaming png files in D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Images/Wheel
Searching...
D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Images/Wheel/aladbl.png to aladmdb.png
D:/Dean/Games/Emulatori/HyperSpin/Media/MAME/Images/Wheel/fatfursa.png to fatfurspa.png
Press Enter to rename, n to skip or Control-C to exit
^CTerminate batch job (Y/N)? y

You see:
1. first directory does not exist - it is skipped - no input needed
2. in second directory no files found - no input needed
3. in third directory - some files found, confirmation is needed - I pressed Enter and files are renamed, you see two step rename on the screen
4. in 4th directory files are found but i pressed n - so dir rename is skipped
5. in 5th dir again some files are found and i pressed Control-C and exited the script

TheManuel
10-13-2010, 08:26 AM
This is a great app!
If I'm going from and old MAME set, several versions older than the current version and all my media files match that MAME set, would I have to run the program once for each MAME version increase that has happened since then or do the renameset dat file also allow you to "jump" between non-contiguous MAME versions?

blur
10-13-2010, 02:21 PM
Follow the link in first post to web page http://www.progettosnaps.net/
There you can find full renameSET rar file (http://www.progettosnaps.net/renSET/pS_renameSET.rar) with all changes from version 1 to 139u3.

You cut the part of file that you need - from one version to another.
ReMAMEr will parse all at once so it is probably better to split it by your two versions and parse two times.

I'm tninking about adding two paremeters - from version and to version and rename of files version by version, not all at once.

Tnx for comments, any ideas are welcome.

TheManuel
10-14-2010, 06:37 AM
Thanks for the reply.
It's not clear to me how your app does the name updating if it does not know from what version your files are.

Can you please explain a little more about your recommendation to split the file and parsing twice? Does that mean that if I'm going from, say 0.136 to 0.139, I should do the updating in parts (0.136 to 0.137, 0.137 to 0.138, etc.)? In fact, should I go by update levels (0.136 to 0.136u1, 0.136u1 to 0.136u2, etc.)?

Thanks again!

blur
10-14-2010, 10:24 PM
it is explained in the posts, first version was parsing whole file and renamed files from bottom to top

version 3 parses whole file, renames all to temporary middle files with awkward names and then to final names. this is done to avoid circular renames a-b, and b-a

you can jump as many versions at ones as you want as long as there is no circular cross references

TheManuel
10-15-2010, 04:36 AM
OK. Thanks.