batch conversion of roms

Get help with running Romcenter 3 here. Please do not post roms requests or illegal links, posts will be deleted.

Moderator: Wanderer

Forum rules
No roms requests or illegal links
nayo
Galaga
Galaga
Posts: 24
Joined: Wed Dec 29, 2010 4:00 am

batch conversion of roms

Post by nayo »

here are 2 nice batch files (to create a .bat file just create a txt file using right click, create txt file, copy the following text, and rename the .txt into .bat)

important, if you have win x64 install 7zip x64, if you got win 32 instal 7zip32

notice: you can batch extract all zipped files selecting them all, right clicking, then selecting extract here option... after doing that move all extracted files and place 7zipall.bat in the newly created or previously emptied folder.

compress all files in a folder into 7z format max compression non solid with multi-threading on:
(call the file 7zipall.bat it checks his name, while scanning all files in its directory to avoid 7zipping himself)

FOR %%i IN (*.*) DO IF NOT (%%i)==(7zipall.bat) "c:\Program Files\7-Zip\7z.exe" a -mx9 -mmt "%%i".7z "%%i"

----------------------------------------------------------------------------------------

now the tricky part: convert all .zip files into .7z (max compression, non solid, using multithreading):
call this file ZipTo7zORviceversa.bat

there is 1 little error left in the modified version of HowardC

error is: the command to make the .zip file deletable is run after the command to delete zip file... so zip file is not deleted, and 1 copy of it is compressed inside the .7z file...

example: game.zip is read only and contains game.nds
using batch file... inside a folder you have game.zip and game.nds... but when game.zip should be deleted... it refuse to cancel itself...
so a game.7z file is created with inside both game.nds and game.zip
at this point the "unprotect command" is run... game.7z is moved to the done folder... while game.zip and game.nds are deleted. but game.zip should have been deleted early... otherwise i now have an unnecessary copy inside the .7z


this is the last version of batch file... who fix this error:

@echo off

SET ConvertFrom=zip
SET ConvertTo=7z

IF NOT EXIST *.zip SET ConvertFrom=7z
IF NOT EXIST *.zip SET ConvertTo=zip

md temp
md done

:LOOP
FOR %%i IN (.\*.%ConvertFrom%) DO (SET varx="%%~ni")
IF NOT EXIST %varx%.%ConvertFrom% GOTO END

move %varx%.%ConvertFrom% .\temp\
cd temp
"c:\Program Files\7-Zip\7z.exe" e %varx%.%ConvertFrom%
attrib -r *
attrib +a *
del %varx%.%ConvertFrom% /Q
"c:\Program Files\7-Zip\7z.exe" a -mx9 -mmt %varx%.%ConvertTo% *
move %varx%.%ConvertTo% .\..\done\
del * /Q
cd..


GOTO LOOP
:END

rd temp
cd done
move * .\..\
cd..
rd done


Posts: 13
Joined: Wed Dec 29, 2010 4:00 am

----------------------------------------------------------------------
TIPS ABOUT ROMCENTER

1) find a way to have every rom 7zipped inside a personal archive (you have as many .7z files as the number or roms)
2) download from nointro datomatic site a "offline list compatible" dat file, choose parent/clone xml
3) extract the .dat file from the .zip archive and place the dat in .\romcenter\romcenter\datas
4)execute romcenter, new,choose dat file and save database
5)change preferences choose merge mode
6) add rom path, and then refresh, fix
7)choose rezip option (it will rearchive in .7z if you chose .7z in preferences)

my rom folder was about 350mb zip
went 230mb 7zipped
went 150mb 7zipped merge, then rezip (rearchive) it took a bit to decompress, recompress everything but in the end i found myself with a rom folder weighting less than half... (-57,1%)
Last edited by nayo on Fri Sep 07, 2012 11:15 pm, edited 7 times in total.

User avatar
RomCenter
Author
Author
Posts: 1519
Joined: Fri Sep 28, 2001 12:34 pm
Location: France
Contact:

Re: batch conversion of roms

Post by RomCenter »

Thanks for the batch. It will be usefull while the function makes its way to romcenter.
Eric - RomCenter developer
Report bugs here.

HowardC

Re: batch conversion of roms

Post by HowardC »

I know this thread is a little old but I wanted to warn people:

DO NOT USE THESE BATS!!!!

They are coded incorrectly and you will corrupt several of your files. The bug involves the fact that many files inside a typical mame zip file do not have a file extension.

Because these bats use "*.*" in several places, and files without extensions don't have a "." they will be omitted.

Here is the corrected file, but it still has a bug where it names the files incorrectly (rom.zip.7z instead of rom.7z).... I'm not sure if this can be corrected via dos commands but if I find a solution I will post it as well.


**************************
@echo off
md temp
md done

:LOOP
FOR %%i IN (.\*.zip) DO (SET varx="%%i")
IF NOT EXIST %varx% GOTO END

move %varx% .\temp\
cd temp
"c:\Program Files\7-Zip\7z.exe" e %varx%
del %varx%
attrib -r *
attrib +a *
"c:\Program Files\7-Zip\7z.exe" a -mx9 -mmt %varx%.7z *
move %varx%.7z .\..\done\
del * /Q
cd..


GOTO LOOP
:END

rd temp
cd done
move * .\..\
cd..
rd done
******************


I hope this helps and remember, *.* is NOT the same thing as * ;-)

HowardC

Re: batch conversion of roms

Post by HowardC »

Sorry my batch file syntax is a tad rusty...... The following batch file works like the one I just posted, only it will properly name the file. If you use this batch file then assuming your rom set was correct prior to conversion you shouldn't need to "fix" anything while in romcenter.

*****************************************
@echo off
md temp
md done

:LOOP
FOR %%i IN (.\*.zip) DO (SET varx="%%~ni")
IF NOT EXIST %varx%.zip GOTO END

move %varx%.zip .\temp\
cd temp
"c:\Program Files\7-Zip\7z.exe" e %varx%.zip
del %varx%.zip
attrib -r *
attrib +a *
"c:\Program Files\7-Zip\7z.exe" a -mx9 -mmt %varx%.7z *
move %varx%.7z .\..\done\
del * /Q
cd..


GOTO LOOP
:END

rd temp
cd done
move * .\..\
cd..
rd done

*******************************

nayo
Galaga
Galaga
Posts: 24
Joined: Wed Dec 29, 2010 4:00 am

Re: batch conversion of roms

Post by nayo »

sorry if my batch file gave some problems on mame files, i tested it with many consoles' set, none of them is without extension

tested with n64 snes nintendo famicon, gameboy, color, advance, sega master system, genesis, 32x
--------------

well now thanks to HowardC the modified batch file will work correctly with mame files too...
i am glad both mame and romcenter now support .7z
i suppose in the future i could pick a look and see if mame + 7z + romcenter are compatible :P



P.S. EDIT: i edited my first post, suggesting to read HowardC second reply for the modified batch file which has now support for mame files

nayo
Galaga
Galaga
Posts: 24
Joined: Wed Dec 29, 2010 4:00 am

Re: batch conversion of roms

Post by nayo »

there is 1 little error left in the modified version of HowardC

error is: the command to make the .zip file deletable is run after the command to delete zip file... so zip file is not deleted, and 1 copy of it is compressed inside the .7z file...

example: game.zip is read only and contains game.nds
using batch file... inside a folder you have game.zip and game.nds... but when game.zip should be deleted... it refuse to cancel itself...
so a game.7z file is created with inside both game.nds and game.zip
at this point the "unprotect command" is run... game.7z is moved to the done folder... while game.zip and game.nds are deleted. but game.zip should have been deleted early... otherwise i now have an unnecessary copy inside the .7z


this is the last version of batch file... who fix this error:

@echo off

SET ConvertFrom=zip
SET ConvertTo=7z

IF NOT EXIST *.zip SET ConvertFrom=7z
IF NOT EXIST *.zip SET ConvertTo=zip

md temp
md done

:LOOP
FOR %%i IN (.\*.%ConvertFrom%) DO (SET varx="%%~ni")
IF NOT EXIST %varx%.%ConvertFrom% GOTO END

move %varx%.%ConvertFrom% .\temp\
cd temp
"c:\Program Files\7-Zip\7z.exe" e %varx%.%ConvertFrom%
attrib -r *
attrib +a *
del %varx%.%ConvertFrom% /Q
"c:\Program Files\7-Zip\7z.exe" a -mx9 -mmt %varx%.%ConvertTo% *
move %varx%.%ConvertTo% .\..\done\
del * /Q
cd..


GOTO LOOP
:END

rd temp
cd done
move * .\..\
cd..
rd done

ZX81v2

Re: batch conversion of roms

Post by ZX81v2 »

Thank you soooo much for this batch code, saved me pulling hair out recompressing 8000+ zip files
Top Notch Work
+Respect

ZX81v2

Locked