7z - .bat file which creates a .zip containing all files with an specific string in its filename












0















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 Files7-Zip7z.exe" a "Chapter %%f" -tzip *c??%%f* 
pause


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).










share|improve this question





























    0















    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 Files7-Zip7z.exe" a "Chapter %%f" -tzip *c??%%f* 
    pause


    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).










    share|improve this question



























      0












      0








      0








      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 Files7-Zip7z.exe" a "Chapter %%f" -tzip *c??%%f* 
      pause


      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).










      share|improve this question
















      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 Files7-Zip7z.exe" a "Chapter %%f" -tzip *c??%%f* 
      pause


      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).







      batch-file zip 7-zip






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 9 at 13:26









      Hennes

      59.1k792141




      59.1k792141










      asked Jan 4 at 2:32









      Nico ElsonNico Elson

      11




      11






















          1 Answer
          1






          active

          oldest

          votes


















          -1














          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).






          share|improve this answer


























          • 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








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1390360%2f7z-bat-file-which-creates-a-zip-containing-all-files-with-an-specific-string%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          -1














          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).






          share|improve this answer


























          • 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
















          -1














          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).






          share|improve this answer


























          • 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














          -1












          -1








          -1







          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).






          share|improve this answer















          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).







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 4 at 9:28

























          answered Jan 4 at 3:15









          ZerteZerte

          173




          173













          • 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



















          • 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

















          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





          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





          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





          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





          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


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1390360%2f7z-bat-file-which-creates-a-zip-containing-all-files-with-an-specific-string%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Список кардиналов, возведённых папой римским Каликстом III

          Deduzione

          Mysql.sock missing - “Can't connect to local MySQL server through socket”