10

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.

1
  • 3
    Imho this is about a default Ubuntu tool and thus on-topic.
    – pLumo
    Commented Sep 28, 2018 at 11:01

1 Answer 1

16

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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .