Shell commands or script to unzip, add text file and rezip

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












I have created 200 zip files for work, but I realized I forgot to add the .txt to each of them. Instead of spending hours redoing this work I'd appreciate any help.



Is there a way anyone knows using bash that will unzip, add the .txt file and rezip all 200 files? The name of the .txt file will not change just the .zip files.



Thank you.










share|improve this question









New contributor




TinyTim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 2




    Imho this is about a default Ubuntu tool and thus on-topic.
    – RoVo
    2 hours ago














up vote
3
down vote

favorite












I have created 200 zip files for work, but I realized I forgot to add the .txt to each of them. Instead of spending hours redoing this work I'd appreciate any help.



Is there a way anyone knows using bash that will unzip, add the .txt file and rezip all 200 files? The name of the .txt file will not change just the .zip files.



Thank you.










share|improve this question









New contributor




TinyTim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 2




    Imho this is about a default Ubuntu tool and thus on-topic.
    – RoVo
    2 hours ago












up vote
3
down vote

favorite









up vote
3
down vote

favorite











I have created 200 zip files for work, but I realized I forgot to add the .txt to each of them. Instead of spending hours redoing this work I'd appreciate any help.



Is there a way anyone knows using bash that will unzip, add the .txt file and rezip all 200 files? The name of the .txt file will not change just the .zip files.



Thank you.










share|improve this question









New contributor




TinyTim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I have created 200 zip files for work, but I realized I forgot to add the .txt to each of them. Instead of spending hours redoing this work I'd appreciate any help.



Is there a way anyone knows using bash that will unzip, add the .txt file and rezip all 200 files? The name of the .txt file will not change just the .zip files.



Thank you.







bash ssh






share|improve this question









New contributor




TinyTim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




TinyTim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 10 mins ago









user535733

6,04522437




6,04522437






New contributor




TinyTim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 3 hours ago









TinyTim

182




182




New contributor




TinyTim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





TinyTim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






TinyTim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 2




    Imho this is about a default Ubuntu tool and thus on-topic.
    – RoVo
    2 hours ago












  • 2




    Imho this is about a default Ubuntu tool and thus on-topic.
    – RoVo
    2 hours ago







2




2




Imho this is about a default Ubuntu tool and thus on-topic.
– RoVo
2 hours ago




Imho this is about a default Ubuntu tool and thus on-topic.
– RoVo
2 hours ago










1 Answer
1






active

oldest

votes

















up vote
6
down vote



accepted










You don't even need to unzip the files, you can update an existing file:



zip -u existing.zip file.txt



from zip manual:



update (-u)
Update existing entries if newer on the file system and add new files.
If the archive does not exist issue warning then create a new archive.


If you want to add a complete folder, add -r.




To update a number of zip files, do something like this:



for z in *.zip; do
zip -u "$z" file.txt
done



See this related question on U&L.






share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    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',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    TinyTim is a new contributor. Be nice, and check out our Code of Conduct.









     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1079177%2fshell-commands-or-script-to-unzip-add-text-file-and-rezip%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    6
    down vote



    accepted










    You don't even need to unzip the files, you can update an existing file:



    zip -u existing.zip file.txt



    from zip manual:



    update (-u)
    Update existing entries if newer on the file system and add new files.
    If the archive does not exist issue warning then create a new archive.


    If you want to add a complete folder, add -r.




    To update a number of zip files, do something like this:



    for z in *.zip; do
    zip -u "$z" file.txt
    done



    See this related question on U&L.






    share|improve this answer


























      up vote
      6
      down vote



      accepted










      You don't even need to unzip the files, you can update an existing file:



      zip -u existing.zip file.txt



      from zip manual:



      update (-u)
      Update existing entries if newer on the file system and add new files.
      If the archive does not exist issue warning then create a new archive.


      If you want to add a complete folder, add -r.




      To update a number of zip files, do something like this:



      for z in *.zip; do
      zip -u "$z" file.txt
      done



      See this related question on U&L.






      share|improve this answer
























        up vote
        6
        down vote



        accepted







        up vote
        6
        down vote



        accepted






        You don't even need to unzip the files, you can update an existing file:



        zip -u existing.zip file.txt



        from zip manual:



        update (-u)
        Update existing entries if newer on the file system and add new files.
        If the archive does not exist issue warning then create a new archive.


        If you want to add a complete folder, add -r.




        To update a number of zip files, do something like this:



        for z in *.zip; do
        zip -u "$z" file.txt
        done



        See this related question on U&L.






        share|improve this answer














        You don't even need to unzip the files, you can update an existing file:



        zip -u existing.zip file.txt



        from zip manual:



        update (-u)
        Update existing entries if newer on the file system and add new files.
        If the archive does not exist issue warning then create a new archive.


        If you want to add a complete folder, add -r.




        To update a number of zip files, do something like this:



        for z in *.zip; do
        zip -u "$z" file.txt
        done



        See this related question on U&L.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 2 hours ago

























        answered 2 hours ago









        RoVo

        5,7291237




        5,7291237




















            TinyTim is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            TinyTim is a new contributor. Be nice, and check out our Code of Conduct.












            TinyTim is a new contributor. Be nice, and check out our Code of Conduct.











            TinyTim is a new contributor. Be nice, and check out our Code of Conduct.













             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1079177%2fshell-commands-or-script-to-unzip-add-text-file-and-rezip%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            Installing NextGIS Connect into QGIS 3?

            One-line joke