Thread: CHD format
View Single Post
Old 22 July 2020, 15:54   #9
Ian
Global Moderator
 
Ian's Avatar
 
Join Date: May 2001
Location: Derby, UK
Age: 46
Posts: 2,287
As ever, testing as you go throws up more issues....

Convert from ISO and WAV to CHD
Code:
SET PATH=C:\Program Files\7-Zip

for %%i in (*.zip) do (
	7z e "%%i"
	for %%g in (*.iso) do (
		if exist "%%~ni.cue" ren "%%~ni.cue" "%%~ni-original.cue"
		.\1-files\piso -y convert "%%g" -o "%%~ng.bin"
		if exist "%%~ni.cue" ren "%%~ni.cue" "%%~ni-piso.cue"
		if exist "%%~ni-original.cue" ren "%%~ni-original.cue" "%%~ni.cue"
		.\1-files\ssr.exe -w "%%g"="%%~ng.bin" "MODE1/2048"="MODE1/2352" "%%~ni.cue"
	)
	.\1-files\chdman createcd -i "%%~ni.cue" -o "%%~ni.chd"
	if exist "*[Track*.*" del /F /Q "*[Track*.*"
	if exist "%%~ni.cue" del /F /Q "%%~ni*.cue"
	if exist "%%~ni.bin" del /F /Q "%%~ni.bin"
	if exist "%%~ni.iso" del /F /Q "%%~ni.iso"
	if not exist .\Originals md Originals
	move "%%i" ".\Originals\%%i"
)
Convert back to ISO and WAV (this is where the fun began - appears TOSEC have added index's to the audio on some cue's, which results in the conversion tool making 2 wavs for each track - probs something else that can do it but this does it and I assume 1:74 is a standard pregap length so will pop up elsewhere)

Code:
SET PATH=C:\Program Files\7-Zip

for %%g in (*.chd) do (
	.\1-files\chdman extractcd -i "%%g" -o "%%~ng.cue" -ob "%%~ng.bin"
	
	for %%h in (*.cue) do (
		.\1-files\binmerge\binmerge.exe -s "%%h" "%%~nh.new"
		.\1-files\ssr.exe -w "    INDEX 00 00:00:00\r\n    INDEX 01 00:01:74"="    INDEX 00 00:00:00" "INDEX 00"="INDEX 01" "%%~nh.new.cue"
		.\1-files\bin2wav.exe "%%~nh.new.cue"
		if exist "%%~nh.new (Track 01).bin" .\1-files\piso convert "%%~nh.new (Track 01).bin" -o "%%~nh.new (Track 01).iso"
		if exist "%%~nh.new (Track 1).bin" .\1-files\piso convert "%%~nh.new (Track 1).bin" -o "%%~nh.new (Track 1).iso"
		del /F /Q "%%h"
	)
	del /F /Q "%%~ng*.bin"
	7z a -tzip "%%~ng.zip" "*.new (Track*.*"
	del /F /Q "*.new*.*"
)
So the tools needed are:
A registered version of poweriso (the free version doesn't do iso's over 300mb) - If anyone knows something free that will convert iso to bin and bin back to iso then please let me know and I will replace this.
Bin2Wav
SSR
Binmerge - this is a python3 script, I have converted it to an exe to suit this purpose but the folder is now 20 mb's due to all the library's it needs to run.
chdman which can be obtained from any MAME distro.
7-zip

All these need to be placed in a folder called 1-files in the directory of the isos you want to convert. as does the code saved as whatever_you_want.bat

The CHD converter moves all the original zips into another folder in the directory you are running it from, for safety.

If you know what you are doing and can do some of this better than this, please let me know.

It's currently working through the games folder, when it's done I will create a dat and see how it goes.

Last edited by Ian; 22 July 2020 at 15:59.
Ian is offline  
 
Page generated in 0.07790 seconds with 11 queries