Original computing articles by a systems administrator

Batch Convert Multiple Bin/Cue files to Iso Files in Linux

I had a bunch of bin/cue disk image files that I needed to convert to .iso files, and the program bchunk didn’t seem to have any way to process multiple files that I could see. So I came up with a command that would do this for me, so if you need to do the same:

  1. Install bchunk: In Ubuntu you can get it by: sudo apt-get install bchunk
  2. Navigate to the directory that has your bin/cue file pairs that you want to convert.
  3. You can convert them all to iso files with the following command, assuming all your bin/cue file pairs have the same root file name, and the extensions are all lowercase: for i in *.cue; do bchunk ${i/.cue}.bin ${i/.cue}.cue ${i/.cue}.iso; done
  4. That should be it, hope this helps someone out. Anyone have a better way?

I will explain how this works for people trying to learn a little bit more about the command line. The bchunk command takes three arguments, and normally would look like “bchunk foo.bin foo.cue. foo.iso”. The command is a for loop, and everything between “do” and the the last semicolon gets repeated as a whole unit for as many times as there are cue files in the current directory (This would be the loop body). The variable i represents each .cue file for each time the loop body is run. “${i/.cue}” strips the file name of its extension (So really “${i/.cue}.cue” is redundant) and the extension that bchunk expects is added with what follows the curly braces.

One Response to Batch Convert Multiple Bin/Cue files to Iso Files in Linux

  1. Nate says:

    Well, it’s a small step from that command to make a shell script (so you don’t have to type it out every time).

    Thanks for the explanation of stripping the extension! That is very useful indeed!

    Much appreciated.

Leave a Reply

*