How to recompress many zips on a drive?












6














I have a hard drive that contains many ZIP files of backups of various things. They were compressed at different points in time in different and inconsistent ways, and a lot of them use minimal compression settings.



Is there a way (preferably with 7zip) to recompress all ZIPs on a drive using the same (best) compression settings?










share|improve this question



























    6














    I have a hard drive that contains many ZIP files of backups of various things. They were compressed at different points in time in different and inconsistent ways, and a lot of them use minimal compression settings.



    Is there a way (preferably with 7zip) to recompress all ZIPs on a drive using the same (best) compression settings?










    share|improve this question

























      6












      6








      6







      I have a hard drive that contains many ZIP files of backups of various things. They were compressed at different points in time in different and inconsistent ways, and a lot of them use minimal compression settings.



      Is there a way (preferably with 7zip) to recompress all ZIPs on a drive using the same (best) compression settings?










      share|improve this question













      I have a hard drive that contains many ZIP files of backups of various things. They were compressed at different points in time in different and inconsistent ways, and a lot of them use minimal compression settings.



      Is there a way (preferably with 7zip) to recompress all ZIPs on a drive using the same (best) compression settings?







      windows windows-10 compression zip 7-zip






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 4 at 15:56









      Julian Lachniet

      6119




      6119






















          4 Answers
          4






          active

          oldest

          votes


















          5





          +100









          Below is a script I've used in the past for a similar task with 100% success that is pure batch with 7Zip where you can explicitly specify the source directory where it can be a drive letter or folder.



          This also allows you to explicitly specify an initial root temp directory and then create a new folder within it matching the name of the zip file minus the zip extension, and then removes it once the 7Zip archive operations are complete for each zip file the For /F loop iterates and processes.



          Script



          You just set the values of the Src=, ExtractDir=, and z7= variable to be whatever they need to be in your environment at the top of the script and the rest will just work.



          You can specify whatever 7Zip compression methods you need at the end of the %z7% a ~ command right after the -aoa switch like -aoa -m<method_parameters> for your needs.



          To run as a batch script though, save the logic to a text document on your desktop, etc. as <something>.cmd from the text document file | save options. Once saved, just double-click it to execute the logic (or right click run as administrator), and confirm the files have been manipulated as expected afterwards.



          @ECHO ON
          SET Src=X:
          SET ExtractDir=%Src%tmpExtract007
          SET z7="C:Program Files7-Zip7z.exe"

          FOR /F "usebackq tokens=*" %%a IN (`DIR /S /B /A-D "%Src%*.zip"`) DO (
          IF NOT EXIST "%ExtractDir%%%~Na" MD "%ExtractDir%%%~Na"
          ECHO A | %z7% e "%%~Fa" -o"%ExtractDir%%%~Na" -r
          %z7% a "%%~Fa" "%ExtractDir%%%~Na*" -aoa
          RD /Q /S "%ExtractDir%%%~Na"
          )
          PAUSE
          EXIT


          Please note the ECHO A | in front of the %z7% e ~ command to tell it to overwrite any existing files that exist in the out directory rather than waiting on you to tell it to do so, etc.



          enter image description here



          Also, please note the use of the -aoa switch at the end of the %z7% a ~ command which tells it to overwrite all existing files within the zip file you are zipping to replacing all original files within it without actually deleting the entire original zip file beforehand which is very simple to add to this script if needed by one additional line of IF EXIST "%%~Fa" DEL /Q /F "%%~Fa".





          Further Resources





          • 7Zip


            • -ao (Overwrite mode) switch

            • 7Zip -m (Set compression Method) switch



          • For /F


          • For /?




            %~fI        - expands %I to a fully qualified path name
            %~nI - expands %I to a file name only
            %~xI - expands %I to a file extension only



          • Dir







          share|improve this answer























          • Can echo A | %z7% e be replaced with -y option to 7-Zip?
            – Alexey Ivanov
            Mar 12 at 16:03










          • This appears to keep the ZIP comment... is there a way to remove them?
            – Julian Lachniet
            Mar 24 at 14:34










          • @JulianLachniet I think just above the line in the loop of %z7% a "%%~Fa" "%ExtractDir%%%~Na*" -aoa you will want to delete the original file first so add IF EXIST "%%~Fa" DEL /Q /F "%%~Fa" in that line above the other line. Then you will not need to use the -aoa switch in the next line. Let me know if that makes sense or if you need more clarification and whether or not that resolves the comment thing. This way the original zip file is deleted and then recreated rather than updated. Give it a shot with a test zip first to confirm but I think that's all you need to do.
            – Pimp Juice IT
            Mar 24 at 21:28










          • @JulianLachniet Here's a link to the new format just to clarify with precision for you what I'm suggesting but please let me know how it goes: textuploader.com/dgvgt
            – Pimp Juice IT
            Mar 24 at 21:30



















          4














          Here's a simple script for regular Command Prompt (cmd.exe) that can do this for you:



          set ZIP7="C:Program Files7-Zip7z.exe"

          for %z in (*.zip) do (
          mkdir tmp
          cd tmp
          %ZIP7% x ..%z
          %ZIP7% a ..%z.7z -r -mx9 *
          cd ..
          rmdir /s /q tmp
          )


          First, ZIP7 variable is defined with the path to 7z.exe. Then for iterates over all zip-files in the current directory. Each zip file is extracted into tmp directory and then recompressed with 7-Zip using maximum compression (-mx9 option).



          You can put these commands in a batch file. In this case, use double % in the for-loop variable. That is, use %%z instead of %z.






          share|improve this answer





























            1














            The ReZip freeware will do the job: zipada55-bin-win32.zip.
            To begin with, the rezip -comp -int archive.zip command will do a fair job without further installation. For an even better compression, you'll need to download zip, 7z, kzip, advzip and run ReZip without the -int option.
            Full set of command line options are:



            Options:  -defl     : repack archive only with the Deflate
            subformat (most compatible)
            -fast_dec : repack archive only with fast decompressing subformats
            -int : use internal Zip-Ada algorithms only, no external call
            -touch : set time stamps to now
            -lower : set full file names to lower case
            -del_comm : delete comment
            -comp : compare original and repacked archives (paranoid mode)
            -rs=n : loop many times over a single compression approach
            having randomization, and keep optimum when size is
            stable after n attempts in a row





            share|improve this answer





























              0














              Write a PowerShell script that finds all zip files on your hard drive, for each zip archive found , extract all files and compress them again in the desired format.



              You can either use builtin ZIP functions or call 7zip command line tools from PowerShell.






              share|improve this answer





















                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%2f1300346%2fhow-to-recompress-many-zips-on-a-drive%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                4 Answers
                4






                active

                oldest

                votes








                4 Answers
                4






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                5





                +100









                Below is a script I've used in the past for a similar task with 100% success that is pure batch with 7Zip where you can explicitly specify the source directory where it can be a drive letter or folder.



                This also allows you to explicitly specify an initial root temp directory and then create a new folder within it matching the name of the zip file minus the zip extension, and then removes it once the 7Zip archive operations are complete for each zip file the For /F loop iterates and processes.



                Script



                You just set the values of the Src=, ExtractDir=, and z7= variable to be whatever they need to be in your environment at the top of the script and the rest will just work.



                You can specify whatever 7Zip compression methods you need at the end of the %z7% a ~ command right after the -aoa switch like -aoa -m<method_parameters> for your needs.



                To run as a batch script though, save the logic to a text document on your desktop, etc. as <something>.cmd from the text document file | save options. Once saved, just double-click it to execute the logic (or right click run as administrator), and confirm the files have been manipulated as expected afterwards.



                @ECHO ON
                SET Src=X:
                SET ExtractDir=%Src%tmpExtract007
                SET z7="C:Program Files7-Zip7z.exe"

                FOR /F "usebackq tokens=*" %%a IN (`DIR /S /B /A-D "%Src%*.zip"`) DO (
                IF NOT EXIST "%ExtractDir%%%~Na" MD "%ExtractDir%%%~Na"
                ECHO A | %z7% e "%%~Fa" -o"%ExtractDir%%%~Na" -r
                %z7% a "%%~Fa" "%ExtractDir%%%~Na*" -aoa
                RD /Q /S "%ExtractDir%%%~Na"
                )
                PAUSE
                EXIT


                Please note the ECHO A | in front of the %z7% e ~ command to tell it to overwrite any existing files that exist in the out directory rather than waiting on you to tell it to do so, etc.



                enter image description here



                Also, please note the use of the -aoa switch at the end of the %z7% a ~ command which tells it to overwrite all existing files within the zip file you are zipping to replacing all original files within it without actually deleting the entire original zip file beforehand which is very simple to add to this script if needed by one additional line of IF EXIST "%%~Fa" DEL /Q /F "%%~Fa".





                Further Resources





                • 7Zip


                  • -ao (Overwrite mode) switch

                  • 7Zip -m (Set compression Method) switch



                • For /F


                • For /?




                  %~fI        - expands %I to a fully qualified path name
                  %~nI - expands %I to a file name only
                  %~xI - expands %I to a file extension only



                • Dir







                share|improve this answer























                • Can echo A | %z7% e be replaced with -y option to 7-Zip?
                  – Alexey Ivanov
                  Mar 12 at 16:03










                • This appears to keep the ZIP comment... is there a way to remove them?
                  – Julian Lachniet
                  Mar 24 at 14:34










                • @JulianLachniet I think just above the line in the loop of %z7% a "%%~Fa" "%ExtractDir%%%~Na*" -aoa you will want to delete the original file first so add IF EXIST "%%~Fa" DEL /Q /F "%%~Fa" in that line above the other line. Then you will not need to use the -aoa switch in the next line. Let me know if that makes sense or if you need more clarification and whether or not that resolves the comment thing. This way the original zip file is deleted and then recreated rather than updated. Give it a shot with a test zip first to confirm but I think that's all you need to do.
                  – Pimp Juice IT
                  Mar 24 at 21:28










                • @JulianLachniet Here's a link to the new format just to clarify with precision for you what I'm suggesting but please let me know how it goes: textuploader.com/dgvgt
                  – Pimp Juice IT
                  Mar 24 at 21:30
















                5





                +100









                Below is a script I've used in the past for a similar task with 100% success that is pure batch with 7Zip where you can explicitly specify the source directory where it can be a drive letter or folder.



                This also allows you to explicitly specify an initial root temp directory and then create a new folder within it matching the name of the zip file minus the zip extension, and then removes it once the 7Zip archive operations are complete for each zip file the For /F loop iterates and processes.



                Script



                You just set the values of the Src=, ExtractDir=, and z7= variable to be whatever they need to be in your environment at the top of the script and the rest will just work.



                You can specify whatever 7Zip compression methods you need at the end of the %z7% a ~ command right after the -aoa switch like -aoa -m<method_parameters> for your needs.



                To run as a batch script though, save the logic to a text document on your desktop, etc. as <something>.cmd from the text document file | save options. Once saved, just double-click it to execute the logic (or right click run as administrator), and confirm the files have been manipulated as expected afterwards.



                @ECHO ON
                SET Src=X:
                SET ExtractDir=%Src%tmpExtract007
                SET z7="C:Program Files7-Zip7z.exe"

                FOR /F "usebackq tokens=*" %%a IN (`DIR /S /B /A-D "%Src%*.zip"`) DO (
                IF NOT EXIST "%ExtractDir%%%~Na" MD "%ExtractDir%%%~Na"
                ECHO A | %z7% e "%%~Fa" -o"%ExtractDir%%%~Na" -r
                %z7% a "%%~Fa" "%ExtractDir%%%~Na*" -aoa
                RD /Q /S "%ExtractDir%%%~Na"
                )
                PAUSE
                EXIT


                Please note the ECHO A | in front of the %z7% e ~ command to tell it to overwrite any existing files that exist in the out directory rather than waiting on you to tell it to do so, etc.



                enter image description here



                Also, please note the use of the -aoa switch at the end of the %z7% a ~ command which tells it to overwrite all existing files within the zip file you are zipping to replacing all original files within it without actually deleting the entire original zip file beforehand which is very simple to add to this script if needed by one additional line of IF EXIST "%%~Fa" DEL /Q /F "%%~Fa".





                Further Resources





                • 7Zip


                  • -ao (Overwrite mode) switch

                  • 7Zip -m (Set compression Method) switch



                • For /F


                • For /?




                  %~fI        - expands %I to a fully qualified path name
                  %~nI - expands %I to a file name only
                  %~xI - expands %I to a file extension only



                • Dir







                share|improve this answer























                • Can echo A | %z7% e be replaced with -y option to 7-Zip?
                  – Alexey Ivanov
                  Mar 12 at 16:03










                • This appears to keep the ZIP comment... is there a way to remove them?
                  – Julian Lachniet
                  Mar 24 at 14:34










                • @JulianLachniet I think just above the line in the loop of %z7% a "%%~Fa" "%ExtractDir%%%~Na*" -aoa you will want to delete the original file first so add IF EXIST "%%~Fa" DEL /Q /F "%%~Fa" in that line above the other line. Then you will not need to use the -aoa switch in the next line. Let me know if that makes sense or if you need more clarification and whether or not that resolves the comment thing. This way the original zip file is deleted and then recreated rather than updated. Give it a shot with a test zip first to confirm but I think that's all you need to do.
                  – Pimp Juice IT
                  Mar 24 at 21:28










                • @JulianLachniet Here's a link to the new format just to clarify with precision for you what I'm suggesting but please let me know how it goes: textuploader.com/dgvgt
                  – Pimp Juice IT
                  Mar 24 at 21:30














                5





                +100







                5





                +100



                5




                +100




                Below is a script I've used in the past for a similar task with 100% success that is pure batch with 7Zip where you can explicitly specify the source directory where it can be a drive letter or folder.



                This also allows you to explicitly specify an initial root temp directory and then create a new folder within it matching the name of the zip file minus the zip extension, and then removes it once the 7Zip archive operations are complete for each zip file the For /F loop iterates and processes.



                Script



                You just set the values of the Src=, ExtractDir=, and z7= variable to be whatever they need to be in your environment at the top of the script and the rest will just work.



                You can specify whatever 7Zip compression methods you need at the end of the %z7% a ~ command right after the -aoa switch like -aoa -m<method_parameters> for your needs.



                To run as a batch script though, save the logic to a text document on your desktop, etc. as <something>.cmd from the text document file | save options. Once saved, just double-click it to execute the logic (or right click run as administrator), and confirm the files have been manipulated as expected afterwards.



                @ECHO ON
                SET Src=X:
                SET ExtractDir=%Src%tmpExtract007
                SET z7="C:Program Files7-Zip7z.exe"

                FOR /F "usebackq tokens=*" %%a IN (`DIR /S /B /A-D "%Src%*.zip"`) DO (
                IF NOT EXIST "%ExtractDir%%%~Na" MD "%ExtractDir%%%~Na"
                ECHO A | %z7% e "%%~Fa" -o"%ExtractDir%%%~Na" -r
                %z7% a "%%~Fa" "%ExtractDir%%%~Na*" -aoa
                RD /Q /S "%ExtractDir%%%~Na"
                )
                PAUSE
                EXIT


                Please note the ECHO A | in front of the %z7% e ~ command to tell it to overwrite any existing files that exist in the out directory rather than waiting on you to tell it to do so, etc.



                enter image description here



                Also, please note the use of the -aoa switch at the end of the %z7% a ~ command which tells it to overwrite all existing files within the zip file you are zipping to replacing all original files within it without actually deleting the entire original zip file beforehand which is very simple to add to this script if needed by one additional line of IF EXIST "%%~Fa" DEL /Q /F "%%~Fa".





                Further Resources





                • 7Zip


                  • -ao (Overwrite mode) switch

                  • 7Zip -m (Set compression Method) switch



                • For /F


                • For /?




                  %~fI        - expands %I to a fully qualified path name
                  %~nI - expands %I to a file name only
                  %~xI - expands %I to a file extension only



                • Dir







                share|improve this answer














                Below is a script I've used in the past for a similar task with 100% success that is pure batch with 7Zip where you can explicitly specify the source directory where it can be a drive letter or folder.



                This also allows you to explicitly specify an initial root temp directory and then create a new folder within it matching the name of the zip file minus the zip extension, and then removes it once the 7Zip archive operations are complete for each zip file the For /F loop iterates and processes.



                Script



                You just set the values of the Src=, ExtractDir=, and z7= variable to be whatever they need to be in your environment at the top of the script and the rest will just work.



                You can specify whatever 7Zip compression methods you need at the end of the %z7% a ~ command right after the -aoa switch like -aoa -m<method_parameters> for your needs.



                To run as a batch script though, save the logic to a text document on your desktop, etc. as <something>.cmd from the text document file | save options. Once saved, just double-click it to execute the logic (or right click run as administrator), and confirm the files have been manipulated as expected afterwards.



                @ECHO ON
                SET Src=X:
                SET ExtractDir=%Src%tmpExtract007
                SET z7="C:Program Files7-Zip7z.exe"

                FOR /F "usebackq tokens=*" %%a IN (`DIR /S /B /A-D "%Src%*.zip"`) DO (
                IF NOT EXIST "%ExtractDir%%%~Na" MD "%ExtractDir%%%~Na"
                ECHO A | %z7% e "%%~Fa" -o"%ExtractDir%%%~Na" -r
                %z7% a "%%~Fa" "%ExtractDir%%%~Na*" -aoa
                RD /Q /S "%ExtractDir%%%~Na"
                )
                PAUSE
                EXIT


                Please note the ECHO A | in front of the %z7% e ~ command to tell it to overwrite any existing files that exist in the out directory rather than waiting on you to tell it to do so, etc.



                enter image description here



                Also, please note the use of the -aoa switch at the end of the %z7% a ~ command which tells it to overwrite all existing files within the zip file you are zipping to replacing all original files within it without actually deleting the entire original zip file beforehand which is very simple to add to this script if needed by one additional line of IF EXIST "%%~Fa" DEL /Q /F "%%~Fa".





                Further Resources





                • 7Zip


                  • -ao (Overwrite mode) switch

                  • 7Zip -m (Set compression Method) switch



                • For /F


                • For /?




                  %~fI        - expands %I to a fully qualified path name
                  %~nI - expands %I to a file name only
                  %~xI - expands %I to a file extension only



                • Dir








                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 11 at 18:30

























                answered Mar 11 at 17:49









                Pimp Juice IT

                22.9k113869




                22.9k113869












                • Can echo A | %z7% e be replaced with -y option to 7-Zip?
                  – Alexey Ivanov
                  Mar 12 at 16:03










                • This appears to keep the ZIP comment... is there a way to remove them?
                  – Julian Lachniet
                  Mar 24 at 14:34










                • @JulianLachniet I think just above the line in the loop of %z7% a "%%~Fa" "%ExtractDir%%%~Na*" -aoa you will want to delete the original file first so add IF EXIST "%%~Fa" DEL /Q /F "%%~Fa" in that line above the other line. Then you will not need to use the -aoa switch in the next line. Let me know if that makes sense or if you need more clarification and whether or not that resolves the comment thing. This way the original zip file is deleted and then recreated rather than updated. Give it a shot with a test zip first to confirm but I think that's all you need to do.
                  – Pimp Juice IT
                  Mar 24 at 21:28










                • @JulianLachniet Here's a link to the new format just to clarify with precision for you what I'm suggesting but please let me know how it goes: textuploader.com/dgvgt
                  – Pimp Juice IT
                  Mar 24 at 21:30


















                • Can echo A | %z7% e be replaced with -y option to 7-Zip?
                  – Alexey Ivanov
                  Mar 12 at 16:03










                • This appears to keep the ZIP comment... is there a way to remove them?
                  – Julian Lachniet
                  Mar 24 at 14:34










                • @JulianLachniet I think just above the line in the loop of %z7% a "%%~Fa" "%ExtractDir%%%~Na*" -aoa you will want to delete the original file first so add IF EXIST "%%~Fa" DEL /Q /F "%%~Fa" in that line above the other line. Then you will not need to use the -aoa switch in the next line. Let me know if that makes sense or if you need more clarification and whether or not that resolves the comment thing. This way the original zip file is deleted and then recreated rather than updated. Give it a shot with a test zip first to confirm but I think that's all you need to do.
                  – Pimp Juice IT
                  Mar 24 at 21:28










                • @JulianLachniet Here's a link to the new format just to clarify with precision for you what I'm suggesting but please let me know how it goes: textuploader.com/dgvgt
                  – Pimp Juice IT
                  Mar 24 at 21:30
















                Can echo A | %z7% e be replaced with -y option to 7-Zip?
                – Alexey Ivanov
                Mar 12 at 16:03




                Can echo A | %z7% e be replaced with -y option to 7-Zip?
                – Alexey Ivanov
                Mar 12 at 16:03












                This appears to keep the ZIP comment... is there a way to remove them?
                – Julian Lachniet
                Mar 24 at 14:34




                This appears to keep the ZIP comment... is there a way to remove them?
                – Julian Lachniet
                Mar 24 at 14:34












                @JulianLachniet I think just above the line in the loop of %z7% a "%%~Fa" "%ExtractDir%%%~Na*" -aoa you will want to delete the original file first so add IF EXIST "%%~Fa" DEL /Q /F "%%~Fa" in that line above the other line. Then you will not need to use the -aoa switch in the next line. Let me know if that makes sense or if you need more clarification and whether or not that resolves the comment thing. This way the original zip file is deleted and then recreated rather than updated. Give it a shot with a test zip first to confirm but I think that's all you need to do.
                – Pimp Juice IT
                Mar 24 at 21:28




                @JulianLachniet I think just above the line in the loop of %z7% a "%%~Fa" "%ExtractDir%%%~Na*" -aoa you will want to delete the original file first so add IF EXIST "%%~Fa" DEL /Q /F "%%~Fa" in that line above the other line. Then you will not need to use the -aoa switch in the next line. Let me know if that makes sense or if you need more clarification and whether or not that resolves the comment thing. This way the original zip file is deleted and then recreated rather than updated. Give it a shot with a test zip first to confirm but I think that's all you need to do.
                – Pimp Juice IT
                Mar 24 at 21:28












                @JulianLachniet Here's a link to the new format just to clarify with precision for you what I'm suggesting but please let me know how it goes: textuploader.com/dgvgt
                – Pimp Juice IT
                Mar 24 at 21:30




                @JulianLachniet Here's a link to the new format just to clarify with precision for you what I'm suggesting but please let me know how it goes: textuploader.com/dgvgt
                – Pimp Juice IT
                Mar 24 at 21:30













                4














                Here's a simple script for regular Command Prompt (cmd.exe) that can do this for you:



                set ZIP7="C:Program Files7-Zip7z.exe"

                for %z in (*.zip) do (
                mkdir tmp
                cd tmp
                %ZIP7% x ..%z
                %ZIP7% a ..%z.7z -r -mx9 *
                cd ..
                rmdir /s /q tmp
                )


                First, ZIP7 variable is defined with the path to 7z.exe. Then for iterates over all zip-files in the current directory. Each zip file is extracted into tmp directory and then recompressed with 7-Zip using maximum compression (-mx9 option).



                You can put these commands in a batch file. In this case, use double % in the for-loop variable. That is, use %%z instead of %z.






                share|improve this answer


























                  4














                  Here's a simple script for regular Command Prompt (cmd.exe) that can do this for you:



                  set ZIP7="C:Program Files7-Zip7z.exe"

                  for %z in (*.zip) do (
                  mkdir tmp
                  cd tmp
                  %ZIP7% x ..%z
                  %ZIP7% a ..%z.7z -r -mx9 *
                  cd ..
                  rmdir /s /q tmp
                  )


                  First, ZIP7 variable is defined with the path to 7z.exe. Then for iterates over all zip-files in the current directory. Each zip file is extracted into tmp directory and then recompressed with 7-Zip using maximum compression (-mx9 option).



                  You can put these commands in a batch file. In this case, use double % in the for-loop variable. That is, use %%z instead of %z.






                  share|improve this answer
























                    4












                    4








                    4






                    Here's a simple script for regular Command Prompt (cmd.exe) that can do this for you:



                    set ZIP7="C:Program Files7-Zip7z.exe"

                    for %z in (*.zip) do (
                    mkdir tmp
                    cd tmp
                    %ZIP7% x ..%z
                    %ZIP7% a ..%z.7z -r -mx9 *
                    cd ..
                    rmdir /s /q tmp
                    )


                    First, ZIP7 variable is defined with the path to 7z.exe. Then for iterates over all zip-files in the current directory. Each zip file is extracted into tmp directory and then recompressed with 7-Zip using maximum compression (-mx9 option).



                    You can put these commands in a batch file. In this case, use double % in the for-loop variable. That is, use %%z instead of %z.






                    share|improve this answer












                    Here's a simple script for regular Command Prompt (cmd.exe) that can do this for you:



                    set ZIP7="C:Program Files7-Zip7z.exe"

                    for %z in (*.zip) do (
                    mkdir tmp
                    cd tmp
                    %ZIP7% x ..%z
                    %ZIP7% a ..%z.7z -r -mx9 *
                    cd ..
                    rmdir /s /q tmp
                    )


                    First, ZIP7 variable is defined with the path to 7z.exe. Then for iterates over all zip-files in the current directory. Each zip file is extracted into tmp directory and then recompressed with 7-Zip using maximum compression (-mx9 option).



                    You can put these commands in a batch file. In this case, use double % in the for-loop variable. That is, use %%z instead of %z.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Mar 11 at 15:51









                    Alexey Ivanov

                    3,59431748




                    3,59431748























                        1














                        The ReZip freeware will do the job: zipada55-bin-win32.zip.
                        To begin with, the rezip -comp -int archive.zip command will do a fair job without further installation. For an even better compression, you'll need to download zip, 7z, kzip, advzip and run ReZip without the -int option.
                        Full set of command line options are:



                        Options:  -defl     : repack archive only with the Deflate
                        subformat (most compatible)
                        -fast_dec : repack archive only with fast decompressing subformats
                        -int : use internal Zip-Ada algorithms only, no external call
                        -touch : set time stamps to now
                        -lower : set full file names to lower case
                        -del_comm : delete comment
                        -comp : compare original and repacked archives (paranoid mode)
                        -rs=n : loop many times over a single compression approach
                        having randomization, and keep optimum when size is
                        stable after n attempts in a row





                        share|improve this answer


























                          1














                          The ReZip freeware will do the job: zipada55-bin-win32.zip.
                          To begin with, the rezip -comp -int archive.zip command will do a fair job without further installation. For an even better compression, you'll need to download zip, 7z, kzip, advzip and run ReZip without the -int option.
                          Full set of command line options are:



                          Options:  -defl     : repack archive only with the Deflate
                          subformat (most compatible)
                          -fast_dec : repack archive only with fast decompressing subformats
                          -int : use internal Zip-Ada algorithms only, no external call
                          -touch : set time stamps to now
                          -lower : set full file names to lower case
                          -del_comm : delete comment
                          -comp : compare original and repacked archives (paranoid mode)
                          -rs=n : loop many times over a single compression approach
                          having randomization, and keep optimum when size is
                          stable after n attempts in a row





                          share|improve this answer
























                            1












                            1








                            1






                            The ReZip freeware will do the job: zipada55-bin-win32.zip.
                            To begin with, the rezip -comp -int archive.zip command will do a fair job without further installation. For an even better compression, you'll need to download zip, 7z, kzip, advzip and run ReZip without the -int option.
                            Full set of command line options are:



                            Options:  -defl     : repack archive only with the Deflate
                            subformat (most compatible)
                            -fast_dec : repack archive only with fast decompressing subformats
                            -int : use internal Zip-Ada algorithms only, no external call
                            -touch : set time stamps to now
                            -lower : set full file names to lower case
                            -del_comm : delete comment
                            -comp : compare original and repacked archives (paranoid mode)
                            -rs=n : loop many times over a single compression approach
                            having randomization, and keep optimum when size is
                            stable after n attempts in a row





                            share|improve this answer












                            The ReZip freeware will do the job: zipada55-bin-win32.zip.
                            To begin with, the rezip -comp -int archive.zip command will do a fair job without further installation. For an even better compression, you'll need to download zip, 7z, kzip, advzip and run ReZip without the -int option.
                            Full set of command line options are:



                            Options:  -defl     : repack archive only with the Deflate
                            subformat (most compatible)
                            -fast_dec : repack archive only with fast decompressing subformats
                            -int : use internal Zip-Ada algorithms only, no external call
                            -touch : set time stamps to now
                            -lower : set full file names to lower case
                            -del_comm : delete comment
                            -comp : compare original and repacked archives (paranoid mode)
                            -rs=n : loop many times over a single compression approach
                            having randomization, and keep optimum when size is
                            stable after n attempts in a row






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Dec 5 at 22:01









                            Zerte

                            91




                            91























                                0














                                Write a PowerShell script that finds all zip files on your hard drive, for each zip archive found , extract all files and compress them again in the desired format.



                                You can either use builtin ZIP functions or call 7zip command line tools from PowerShell.






                                share|improve this answer


























                                  0














                                  Write a PowerShell script that finds all zip files on your hard drive, for each zip archive found , extract all files and compress them again in the desired format.



                                  You can either use builtin ZIP functions or call 7zip command line tools from PowerShell.






                                  share|improve this answer
























                                    0












                                    0








                                    0






                                    Write a PowerShell script that finds all zip files on your hard drive, for each zip archive found , extract all files and compress them again in the desired format.



                                    You can either use builtin ZIP functions or call 7zip command line tools from PowerShell.






                                    share|improve this answer












                                    Write a PowerShell script that finds all zip files on your hard drive, for each zip archive found , extract all files and compress them again in the desired format.



                                    You can either use builtin ZIP functions or call 7zip command line tools from PowerShell.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Mar 4 at 17:09









                                    Peter Hahndorf

                                    8,58953758




                                    8,58953758






























                                        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.





                                        Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                        Please pay close attention to the following guidance:


                                        • 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%2f1300346%2fhow-to-recompress-many-zips-on-a-drive%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

                                        Paul Cézanne

                                        UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

                                        Angular material date-picker (MatDatepicker) auto completes the date on focus out