I have a folder containing an entire volume of a comic book, 9 chapters in total, with both .png and .jpg files.

Each filename is [Series Name] c*** v**.png

I want to make a batch file which compresses all files of a specific chapter in a zip file called Chapter ***.zip, regardless of filetype.

I know little of programming, so I kept searching the web, finding nothing. My attempts at editing pre-made .bats did nothing in the end.

It worked, after a bit of trial and error with the wildcards. The end code is

for /l %%f in (1,1,9) do "c:\Program Files\7-Zip\7z.exe" a "Chapter %%f" -tzip *c??%%f* 

Now that I go to double-digit chapter number, I believe I'll have to erase one ? from the end string, not to say change the (1,1,9).


Here you are, with 7z:

for /l %%c in (1,1,9) do 7z a "Chapter %%c" -tzip c%%c* 

For more information about the "for" instruction, type for /? in the command line (cmd.exe).

  • Welcome to Super User. If you can, teach us by explaining a little about how this command works. While obtaining the end goal is great, learning on the way is even better. Thanks for contributing. – Twisty Impersonator Jan 4 at 3:37
  • I agree with Twisty Impersonator if you show what each part of the command does the person would have a better idea of what to do in the future. Which would help other users in learning what they need to fix the issue. – NetworkKingPin Jan 4 at 3:41
  • Even if OP is a bit unclear, what about the series name? Your line will only add files to the archive which start with the letter c followed by 1..9 – LotPings Jan 4 at 10:07
  • Thanks for the help, it does create the files, but doesn't compress anything, most likely due to LotPings point. I'll try to fix the filename syntax myself, but any help would be greatly appreciated. – Nico Elson Jan 4 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.