8

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.

  • 3
    Imho this is about a default Ubuntu tool and thus on-topic. – pLumo Sep 28 '18 at 11:01
14

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.

| improve this answer | |

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.