Log in

Comics: Convert CBR to CBZ

Comics are great. I'd gotten out of the habit but I still enjoy picking up a good Batman story now and again, but other than that it is hard to know what to pick. The painted comics of Alex Ross (Kingdom Come) are beautiful, the stories of Warren Ellis (Transmetropolitan) are compelling.

Can you judge a book by it's cover? If it is a graphic design book, or art book I think you can and with comics I often do choose on that basis (and all too often get caught out when the interior art is entirely different from the cover). In the long run though it is stories and the writers that keep me coming back and if I particularly like the style of the artist that is a bonus.

Chatting with the local equivalent of Comic Book Guy is one way to get ideas of what to try but picking a book off a shelf and having a look is usually the best way. The internet has provided us with an even bigger bookshelf to flick through, and there are groups who scan the latest comic books and package them up for easy sampling, usually a series of JPEG image files packaged together as a single convenient archive. Very often this archive they are packaged in use RAR compression CBR (Comic Book RAR archive), but other times the container uses Zip compression CBZ (Comic Book Zip archive). The essential difference is that Zip is free and RAR is proprietary.

I wanted to convert these CBR files to CBZ. I could do that by unpacking and repacking the files on a case by case basis but that is repetative and uninteresting. Instead I decided to make things more complicated and come up with a more general automated solution. That solution might be of use to others, especially those who do not know how to write MSDOS batch files, so I'm sharing it. On the internet there is almost always someone else who has the same idea as you, and I was able to find something very close: Andrew Armstrong had already written a Mass Zip, RAR to 7Zip Recompression Batch File and all I needed to do was make some small adjustments so that it would to convert RAR files and CBR files into CBZ files. It took me far less time to make my changes than it to write them up and explain them, the hard work was already done. If you want details of what exactly is happening you should read his detailed description, otherwise skip to the end.

The script requires the excellent free compression program 7-zip and you must have it installed. To keep things simple we assume 7-zip is installed in the default location C:\Program Files\7-zip\7z and we do not try to check. If for example you were using a German version of Microsoft Windows 7-zip might be installed in a folder called "Programme" rather than "Program Files" or if you wanted to use a portable flash drive and use Portable 7-zip you would also need to change the program before it would work. (We could try to avoid the first problem by checking to see if %ProgramFiles% is C:\Program Files as expected.

Another known issue the sometimes causes the script to fail is when file path names are too long. Microsoft Windows limits file names to 260 characters in length. The script creates a temporary folder based on the name of the CBR and if there is a subfolder inside the CBR the filename can sometimes be too long.

As this script is intended to be used to unpack not just any generic RAR file but a Comic Book Archive there are other changes we can include. Creators of Comic Book archives compress a whole folder instead of picking out just the picture files they want, and all sorts of other things get included by mistake. Microsoft Windows includes a hidden file called Thumbs.db which stores thumbnail images of your files. We can safely delete this, Windows will recreate it if the comic book archive is ever unpacked and it is needed. To do this I added the line DEL /F /S /Q Thumbs.db (which is short for DELete by Force, in all Subdirectories, and do it Quietly without reporting any errors).

The scanners who create Comic Book archives often like to include a banner image saying who they are and often with a message such as reminding readers that if they like the comic they should buy it too. These files are often given a file name starting with 'Z' so that it will appear last in the sequence so I added another line to delete any file that starts with the letter 'Z' DEL /F /S /Q z*.*. If the banner image has a different name this won't work but it is an example of what you can do to fit the generic scripts to better fit that task.

One change I have made might seem surprising. I have set the Zip compression to level zero, which is no compression at all (-mx=0). I could save a small amount of space by using the maximum amount of compression but this would take longer to pack the files, and more importantly it would make it slower each and every time you want to unpack and read the files. The Zip archive convenient container to make things easier to organize, and JPEG files are already quite heavily compressed.

If you want to try it out for your self, copy the commands below into a text file, change the name to cbr2cbz.bat or similar, put it in a folder with some CBR or RAR files and away you go.

REM Based on 
REM Mass Zip, RAR to 7Zip Recompression Batch File by Andrew Armstrong
REM http://aarmstrong.org/tutorials/mass-zip-rar-to-7zip-recompression-batch-file
REM Find all .cbr and .rar files in the current directory, recompress them into .cbz and .zip files - but do not delete the originals.

ECHO Searching for CBR and RAR files to recompress into CBZ (Comic Book Zip) archives.

for %%F in (*.cbr *.rar) do (
ECHO Found %%F to recompress...
REM Extract...
"C:\Program Files\7-zip\7z" x "%%F" -o"%%F contents"
REM Does the directory exist? has 7zip created it correctly?
IF EXIST "%%F contents" (
REM Change directory, create zip of contents of directory...
CD "%%F contents"
REM remove banners 
DEL /F /S /Q z*.*
REM Delete Thumbnail files. 
DEL /F /S /Q Thumbs.db
REM compression level is 0, store only. 
"C:\Program Files\7-zip\7z" a -tzip "../%%~nF.cbz" * -mx=0
CD ..
REM Delete the temporary extraction folder
RMDIR "%%F contents" /S /Q
ECHO Recompressed %%F to %%~nF.zip
ECHO Search ended.



Thumbs.db files not deleted

I've noticed that Thumbs.db files were not being deleted, which is annoying since they are quite a significant waste of space.
Part of the reason these get accidentally included in the first place is because they are System files and automatically hidden by Microsoft Windows. I changed the DOS delete command to specify we want to delete these special files that have been marked with the 'System' attribute. This seems to work more of the time.

DEL /F /S /Q Thumbs.db
DEL /F /S /Q /A:S Thumbs.db


Hello Alan,

I know it's 2 years later, but I've been looking for something like this for a while. I just wanted to thank you for the work you've done and leaving it up on the net.

Quick question (in case you get this): I have been practicing with your program but, "what if scenario..." I had a comic with "Zone" in front of every jpg. I checked it and it deleted every jpg. What do you think I should do in those cases? Is there a quick fix to the script?

Thank you for your time. I really appreciate it.

fifthof9 at gmail
I changed the script to remove any files beginning with "team" (team DCP used to be a thing) and occasionally I got caught out, and I guess you had the same problem with file beginning with Z, I think I hit that with a few zombie comics too.

Probably best to change the script to not delete anything, so remove the lines with DEL or MOVE and then rerun the batch file. I don't have a better answer, I get caught out sometimes too.

Edited at 2015-04-10 12:40 am (UTC)


I'm not sure if you'll ever read this, since this post is a couple of years old. I just wanted to say THANK YOU!
Thank you. I'm glad it was useful.
Hi! I just had a quick question. I have just found this page, and I've been using this script like crazy. I have been streaming my comics to my iPad with an app called AirBookHome, and while it's a fantastic interface, it doesn't read .cbr files, probably because Apple doesn't recognize WinRAR's file formatting (my best guess). So essentially, your script has been a lifesaver.

My only problem is that I have to go back and delete all the old CBR files after I've converted them. I'm not knowledgeable about these kinds of commands, so I wanted to ask if there is any kind of addition I could make to the script to make it delete the original files once I've converted them. Can you help?

Thanks again.

- J

Better safe than sorry.

I'd be very worried about automatically deleting anything.

It is possible but I think it is better to be safe than sorry. Even if it does mean an extra step, it is not something I'd do because it would be terrible if there was a bad error.

You. I adore you. Thank you so so much.

This works flawlessly.
I might have figured it out on my own but I'd like to thank Andrew Armstrong for making it so easy.

I also recommend Peazip which has an automated RAR to ZIP converter, only last I checked it wasn't so useful for converting CBR (although that was a while back and maybe it works better now).


Very nice cbr2cbz script. But i'm looking for something like this for an Android tablet. Anyone out there to point me in the right direction?

RAR must die

I've seen similar scripts written in python. If you search you might find them. You might try using Peazip to convert from RAR to ZIP and then using another program to rename from ZIP to CBZ.

The difficult part is converting the RAR file. There might not be suitable RAR softare available for you tablet computer.

Even if you do find Android software that can convert RAR it will be very slow compared to ZIP/CBZ. That is a big part of the reason I created this script, so that I could convert files BEFORE copying them to other devices, since RAR is so awful.

ACV Android Comic Viewer is quite good but RAR still causes problems:


Hi Alan
I just converted some cbr-files with your bat-file and it worked just fine. Thanks.


June 2015



Powered by LiveJournal.com