GithubHelp home page GithubHelp logo

binmerge's Introduction

binmerge

Source code available at: https://github.com/putnam/binmerge

Tool to merge multiple bin/cue tracks into one.

Usage

To get the command line help for binmerge, use ./binmerge --help.

Example: Merge a split image

To merge a set of bin files for a given cuesheet:

./binmerge "/path/to/My Great Game.cue" "My Great Game (Merged)"

This will create two new files, "My Great Game (Merged).bin" and "My Great Game (Merged).cue". These will be created alongside your existing files in the same directory unless specified otherwise.

To control the output directory, use the --outdir flag:

./binmerge --outdir "/mnt/stuff/merged-games" "/path/to/My Great Game.cue" "My Great Game (Merged)"

Example: Split a merged image

If you want to reverse the process and create split files again, binmerge supports that. But do note, for some games, the Redump cuesheet contains information that binmerge cannot reasonably preserve when merging. If you're trying to get back to a pristine Redump set, you may want to download the freely available cuesheets available on Redump's web site.

To split a merged bin/cue:

./binmerge --split --outdir "/mnt/stuff/split-games" "/path/to/My Great Game.cue" "My Great Game"

This will create a new cue sheet and a series of .bin files, like this:

My Great Game.cue
My Great Game (Track 1).bin
My Great Game (Track 2).bin

As before, if outdir is not specified, the new files will be written alongside the existing files.

Rationale

Sometimes discs are ripped in such a way that they have a separate bin file for every track. One example that I know of is the Redump project, specifically for the Playstation 1 or PSX.

Here is a cuesheet for the imaginary PSX game "Big Buddy". You can see it refers to several individual bin files, one for each track:

FILE "Big Buddy (Track 01).bin" BINARY
  TRACK 01 MODE2/2352
    INDEX 01 00:00:00
FILE "Big Buddy (Track 02).bin" BINARY
  TRACK 02 AUDIO
    INDEX 00 00:00:00
    INDEX 01 00:02:00
FILE "Big Buddy (Track 03).bin" BINARY
  TRACK 03 AUDIO
    INDEX 00 00:00:00
    INDEX 01 00:02:00
FILE "Big Buddy (Track 04).bin" BINARY
  TRACK 04 AUDIO
    INDEX 00 00:00:00
    INDEX 01 00:02:00
FILE "Big Buddy (Track 05).bin" BINARY
  TRACK 05 AUDIO
    INDEX 00 00:00:00
    INDEX 01 00:02:00
...

Some software cannot read this style of disc image, because they only know how to work with a single bin file or are unable to properly parse cuesheets according to the standard.

binmerge reads a cuesheet and its associated series of bin files and generates a new, single merged bin file and cuesheet. It is completely non-destructive and does not touch your existing files.

Here is the new cuesheet generated by binmerge with the above example:

FILE "Big Buddy.bin" BINARY
  TRACK 01 MODE2/2352
    INDEX 01 00:00:00
  TRACK 02 AUDIO
    INDEX 00 32:26:61
    INDEX 01 32:28:61
  TRACK 03 AUDIO
    INDEX 00 35:43:29
    INDEX 01 35:45:29
  TRACK 04 AUDIO
    INDEX 00 36:47:27
    INDEX 01 36:49:27
  TRACK 05 AUDIO
    INDEX 00 38:50:66
    INDEX 01 38:52:66

Have fun!

binmerge's People

Contributors

cgarz avatar putnam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

binmerge's Issues

request: add cdrdao TOC support

on a MacBookPro9,2 running 10.15.7, i get this error running "--split" with a cdrdao ripped fighters megamix saturn ROM. log below:
mokman23@Catalina-MBP Downloads % ./binmerge --split fightersmegamix.cue fightersmegamix.bin [INFO] Output directory: /Users/mokman23/Downloads [INFO] Opening cue: /Users/mokman23/Downloads/fightersmegamix.cue Traceback (most recent call last): File "./binmerge", line 367, in <module> if not main(): File "./binmerge", line 332, in main cuesheet = gen_split_cuesheet(args.basename, cue_map[0]) IndexError: list index out of range

Update binmerge exe

There are plans for an update the windows exe with the newest optimizations (relative paths os.path.basename) and new changes from you.
You can add the version string in the help informations.

Hope you're still active

Let me start by saying I love your script! It seems to work flawlessly. I do have one issue that you may or may not be able to change. When it creates the cue file it points to the full path of the bin. It would be nice if it only pointed at the file.

So instead of it pointing at this is\the path

Relative paths don't work

Hi,
I was trying to create a batch file in order to use your script quickly.
The batch file and the file [binmerge.py] are in the folder "C:\binmerge"
My bin files are in "C:\binmerge\Bins"
and I made a new folder "C:\binmerge\Merged"

(Not working) This is the content of the .bat Batch file:
for /r %%i in (*.cue) do binmerge.py "%%i" "%%~ni.merged" -o "%~dp0\Merged"

But it works with:
for /r %%i in (*.cue) do binmerge.py "%%i" "%%~ni.merged" -o "C:\binmerge\Merged"

Setting output directory only directs the .cue file when using --split?

What I was aiming for was to take the .cue and .bin in "input" folder, do the splitting, and then output both the .cue and .bin(s) to the "output" folder.

My batch is as follows:

set "CueFileName=%%~ni"
for %%i in (input\*.cue) do (binmerge -o output -s "%%i" "%CueFileName%")

and this does correctly split the files, however it only puts the new .cue file in the "output" folder, and just spits the .bin files next to the binmerge.exe rather than also in "output".

I'm not well versed so I'm not sure if it's because of my batch or if this is unintended behaviour?

I appreciate your program ๐Ÿ’œ

Dreamcast redump reversal

Initial tests show that a redump dreamcast .cue file has 2 remarks in it in the original cue file:

REM SINGLE-DENSITY AREA
before the first 2 tracks and
REM HIGH-DENSITY AREA
between track 2 and 3, track 3 and up being the bulk of the data

can there be a commandline switch added to -fixdccue or some such?

Invalid escape sequence \d

I'm getting this message when attempting to run master with Python 3.12.1 on Windows

PS ...> binmerge.py
...\binmerge.py:122: SyntaxWarning: invalid escape sequence '\d'
  m = re.search('TRACK (\d+) ([^\s]*)', line)
...\binmerge.py:128: SyntaxWarning: invalid escape sequence '\d'
  m = re.search('INDEX (\d+) (\d+:\d+:\d+)', line)
...\binmerge.py:169: SyntaxWarning: invalid escape sequence '\d'
  m = re.match("(\d+):(\d+):(\d+)", stamp)
usage: binmerge.py [-h] [-l] [-v] [-s] [-o OUTDIR] cuefile basename
binmerge.py: error: the following arguments are required: cuefile, basename

Seems like some of these strings are missing r prefixes.

Audio with 2 indexes creates to seperate bin files - Not an issue!!!

Hi Hope you are well.

I have been trying to convert a lot of my sets to CHD but want to make sure I can reverse the process. Some sets have two index's per audio section, which when used creates two bin's per track which then do not match the originals.

An example cuesheet is attached.

Is there a way to get binmerge to ignore the index's and just create one file per track?

Kind regards

Ian

Alien Breed 3D (1995)(Ocean - Team 17)[!][cp code].txt

Receiving 'FileNotFoundError: [Errno 2] No such file or directory: Error

Hey there,

I found your utility via a 'gotbletu' video on YouTube:
https://www.youtube.com/watch?v=eJOO5tpWZU0

My current issue is that I am trying to merge two separate .bin files that were ripped for the "Dynasty Warriors 2" game into 1 .bin using the available .cue file present.

It appears to be erroring out on Line 98 where you are obtaining the size of the file itself using the 'os' library.

I am getting this error on a box using Fedora Server for reference.

Here's the output:

sam@fedoraserver ~/utilities/binmerge $ ls
 binmerge  'Dynasty Warriors 2.cue'  'Dynasty Warriors 2 (Track 1).bin'  'Dynasty Warriors 2 (Track 2).bin'   LICENSE   README.md
sam@fedoraserver ~/utilities/binmerge $ ./binmerge 'Dynasty Warriors 2.cue' 'Dynasty Warriors 2'
[INFO]  Opening cue: Dynasty Warriors 2.cue
Traceback (most recent call last):
  File "/home/sam/utilities/binmerge/./binmerge", line 306, in <module>
    if not main():
  File "/home/sam/utilities/binmerge/./binmerge", line 266, in main
    cue_map = read_cue_file(args.cuefile)
  File "/home/sam/utilities/binmerge/./binmerge", line 109, in read_cue_file
    this_file = File(os.path.join(os.path.dirname(cue_path), m.group(1)))
  File "/home/sam/utilities/binmerge/./binmerge", line 98, in __init__
    self.size = os.path.getsize(filename)
  File "/usr/lib64/python3.9/genericpath.py", line 50, in getsize
    return os.stat(filename).st_size
FileNotFoundError: [Errno 2] No such file or directory: 'Dynasty Warriors 2 (USA) (Track 1).bin'

Thanks for the utility, looks cool!

Output subdir ends up on .cue after merge

I admit this might be me not being good at batch.
I do this:
merge.bat

for %%A in ("%~1") do set "InputFileName=%%~nA"
binmerge.exe "%~1" "merged\%InputFileName%"

The problem is the .cue file ends up picking up the "merged" directory like so:
FILE "merged\file.bin" BINARY
When it should just be:
FILE "file.bin" BINARY

ANything i can do in batch to fix this or it's just how the .exe works?

Crashes on startup

Downloaded the win64 file. Opened the executable. Just shows an empty command box and crashes in the span of half a second.

Thanks for making binmerge, is there a binsplit?

Firstly I must say thanks for making bin merge. Everything I was able to find on Google was windows specific. IsoBuster and the like. Even the answers to people asking about doing it on Linux were "go do it on windows" which I thought was awful. I only found binmerge after deciding to search GitHub specifically.

So thanks a bunch! Binmerge deserves more coverage! =D

One problem though. I would like to be able to return to the Redump.org format with the multiple bin files in order to verify against their dat files. So is there a binsplit?

Request: Do not add ` (Track %s)` suffix on single track discs on `--split`

I've noticed binmerge is careful enough to use a leading 0 when there are more than 10 tracks, to match Redump's naming convention. It could go one step further and not add the (Track %s) at all if there is only a single track, so the BIN file has the same name as the CUE file.

Granted, one could argue that this is a no-op, as the output files would be identical to the input ones, so the solution would be simply not to invoke binmerge at all. True, but parsing the original CUE to determine if binmerge should be bypassed or not is a much more complex pipeline than simply chdman extractcd ... && binmerge --split ..., so I believe this "no-op" feature is worth having

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.