Terminal command to add a directory to many existing zip files

Clash Royale CLAN TAG#URR8PPP
I am using the below command in Terminal, found here from this answer by @Theophrastus to zip all *.html and *.js files with the same name, while retaining the name of those paired files.
How to zip files with same name but different extension?
for Q in *;do H=$Q%%.*;zip "$H.zip" "$Q";done
I would like to also have a folder called images included in the zip file, but do not understand what the command above does.
I have searched extensively for how to add to an existing zip file, and read the zip man files.
I apologize for making this a two part question, when it did not need to be. Below is what I tried before asking the question.
The following works with a specified file name.
zip -ur exactfilename.zip images
I have tried to implement wild cards, with no success
zip -ur *.zip images
zip -ur %%.zip images
zip -ur ?.zip images
Structure is
zipping
|- images
bitmap.jpg
bitmap.png
zip1.zip
zip2.zip
zip3.zip
zip4.zip
zip5.zip
zip6.zip
zip.7.zip
zip8.zip
zip9.zip
zip10.zip
zip11.zip
command-line terminal zip
|
show 3 more comments
I am using the below command in Terminal, found here from this answer by @Theophrastus to zip all *.html and *.js files with the same name, while retaining the name of those paired files.
How to zip files with same name but different extension?
for Q in *;do H=$Q%%.*;zip "$H.zip" "$Q";done
I would like to also have a folder called images included in the zip file, but do not understand what the command above does.
I have searched extensively for how to add to an existing zip file, and read the zip man files.
I apologize for making this a two part question, when it did not need to be. Below is what I tried before asking the question.
The following works with a specified file name.
zip -ur exactfilename.zip images
I have tried to implement wild cards, with no success
zip -ur *.zip images
zip -ur %%.zip images
zip -ur ?.zip images
Structure is
zipping
|- images
bitmap.jpg
bitmap.png
zip1.zip
zip2.zip
zip3.zip
zip4.zip
zip5.zip
zip6.zip
zip.7.zip
zip8.zip
zip9.zip
zip10.zip
zip11.zip
command-line terminal zip
check out theformatting button to format code separately; it makes it much more readable. Thanks!
– Jeff Schaller
Feb 11 at 15:25
1
Tryfor file in *.zip ; do zip -ur "$file" images ; done
– Bodo
Feb 11 at 15:33
I'm being misled by the introduction in the question; is there anything about matching or paired filenames that are important to you?
– Jeff Schaller
Feb 11 at 15:56
Thank you so much Bodo! That works.
– Susan Forman
Feb 11 at 15:56
Just that the files being zipped initially are an html file that has a js file with the same name.
– Susan Forman
Feb 11 at 15:57
|
show 3 more comments
I am using the below command in Terminal, found here from this answer by @Theophrastus to zip all *.html and *.js files with the same name, while retaining the name of those paired files.
How to zip files with same name but different extension?
for Q in *;do H=$Q%%.*;zip "$H.zip" "$Q";done
I would like to also have a folder called images included in the zip file, but do not understand what the command above does.
I have searched extensively for how to add to an existing zip file, and read the zip man files.
I apologize for making this a two part question, when it did not need to be. Below is what I tried before asking the question.
The following works with a specified file name.
zip -ur exactfilename.zip images
I have tried to implement wild cards, with no success
zip -ur *.zip images
zip -ur %%.zip images
zip -ur ?.zip images
Structure is
zipping
|- images
bitmap.jpg
bitmap.png
zip1.zip
zip2.zip
zip3.zip
zip4.zip
zip5.zip
zip6.zip
zip.7.zip
zip8.zip
zip9.zip
zip10.zip
zip11.zip
command-line terminal zip
I am using the below command in Terminal, found here from this answer by @Theophrastus to zip all *.html and *.js files with the same name, while retaining the name of those paired files.
How to zip files with same name but different extension?
for Q in *;do H=$Q%%.*;zip "$H.zip" "$Q";done
I would like to also have a folder called images included in the zip file, but do not understand what the command above does.
I have searched extensively for how to add to an existing zip file, and read the zip man files.
I apologize for making this a two part question, when it did not need to be. Below is what I tried before asking the question.
The following works with a specified file name.
zip -ur exactfilename.zip images
I have tried to implement wild cards, with no success
zip -ur *.zip images
zip -ur %%.zip images
zip -ur ?.zip images
Structure is
zipping
|- images
bitmap.jpg
bitmap.png
zip1.zip
zip2.zip
zip3.zip
zip4.zip
zip5.zip
zip6.zip
zip.7.zip
zip8.zip
zip9.zip
zip10.zip
zip11.zip
command-line terminal zip
command-line terminal zip
edited Feb 11 at 16:33
Susan Forman
asked Feb 11 at 15:17
Susan FormanSusan Forman
62
62
check out theformatting button to format code separately; it makes it much more readable. Thanks!
– Jeff Schaller
Feb 11 at 15:25
1
Tryfor file in *.zip ; do zip -ur "$file" images ; done
– Bodo
Feb 11 at 15:33
I'm being misled by the introduction in the question; is there anything about matching or paired filenames that are important to you?
– Jeff Schaller
Feb 11 at 15:56
Thank you so much Bodo! That works.
– Susan Forman
Feb 11 at 15:56
Just that the files being zipped initially are an html file that has a js file with the same name.
– Susan Forman
Feb 11 at 15:57
|
show 3 more comments
check out theformatting button to format code separately; it makes it much more readable. Thanks!
– Jeff Schaller
Feb 11 at 15:25
1
Tryfor file in *.zip ; do zip -ur "$file" images ; done
– Bodo
Feb 11 at 15:33
I'm being misled by the introduction in the question; is there anything about matching or paired filenames that are important to you?
– Jeff Schaller
Feb 11 at 15:56
Thank you so much Bodo! That works.
– Susan Forman
Feb 11 at 15:56
Just that the files being zipped initially are an html file that has a js file with the same name.
– Susan Forman
Feb 11 at 15:57
check out the
formatting button to format code separately; it makes it much more readable. Thanks!– Jeff Schaller
Feb 11 at 15:25
check out the
formatting button to format code separately; it makes it much more readable. Thanks!– Jeff Schaller
Feb 11 at 15:25
1
1
Try
for file in *.zip ; do zip -ur "$file" images ; done– Bodo
Feb 11 at 15:33
Try
for file in *.zip ; do zip -ur "$file" images ; done– Bodo
Feb 11 at 15:33
I'm being misled by the introduction in the question; is there anything about matching or paired filenames that are important to you?
– Jeff Schaller
Feb 11 at 15:56
I'm being misled by the introduction in the question; is there anything about matching or paired filenames that are important to you?
– Jeff Schaller
Feb 11 at 15:56
Thank you so much Bodo! That works.
– Susan Forman
Feb 11 at 15:56
Thank you so much Bodo! That works.
– Susan Forman
Feb 11 at 15:56
Just that the files being zipped initially are an html file that has a js file with the same name.
– Susan Forman
Feb 11 at 15:57
Just that the files being zipped initially are an html file that has a js file with the same name.
– Susan Forman
Feb 11 at 15:57
|
show 3 more comments
1 Answer
1
active
oldest
votes
You cannot specify wildcards as the zip file argument for the zip command because the shell would replace this with multiple file names. Instead you can use a loop to process multiple zip files one by one.
file in *.zip
do
zip -ur "$file" images
done
or in one line
for file in *.zip ; do zip -ur "$file" images ; done
or initially withfor Q in *;do H=$Q%%.*;zip "$H.zip" images "$Q";done
– Jeff Schaller
Feb 11 at 16:01
That also works, Jeff Schaller. The way that Animate CC publishes canvas files, is that there is only an images folder, if there are bitmaps.
– Susan Forman
Feb 11 at 16:20
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f499967%2fterminal-command-to-add-a-directory-to-many-existing-zip-files%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
You cannot specify wildcards as the zip file argument for the zip command because the shell would replace this with multiple file names. Instead you can use a loop to process multiple zip files one by one.
file in *.zip
do
zip -ur "$file" images
done
or in one line
for file in *.zip ; do zip -ur "$file" images ; done
or initially withfor Q in *;do H=$Q%%.*;zip "$H.zip" images "$Q";done
– Jeff Schaller
Feb 11 at 16:01
That also works, Jeff Schaller. The way that Animate CC publishes canvas files, is that there is only an images folder, if there are bitmaps.
– Susan Forman
Feb 11 at 16:20
add a comment |
You cannot specify wildcards as the zip file argument for the zip command because the shell would replace this with multiple file names. Instead you can use a loop to process multiple zip files one by one.
file in *.zip
do
zip -ur "$file" images
done
or in one line
for file in *.zip ; do zip -ur "$file" images ; done
or initially withfor Q in *;do H=$Q%%.*;zip "$H.zip" images "$Q";done
– Jeff Schaller
Feb 11 at 16:01
That also works, Jeff Schaller. The way that Animate CC publishes canvas files, is that there is only an images folder, if there are bitmaps.
– Susan Forman
Feb 11 at 16:20
add a comment |
You cannot specify wildcards as the zip file argument for the zip command because the shell would replace this with multiple file names. Instead you can use a loop to process multiple zip files one by one.
file in *.zip
do
zip -ur "$file" images
done
or in one line
for file in *.zip ; do zip -ur "$file" images ; done
You cannot specify wildcards as the zip file argument for the zip command because the shell would replace this with multiple file names. Instead you can use a loop to process multiple zip files one by one.
file in *.zip
do
zip -ur "$file" images
done
or in one line
for file in *.zip ; do zip -ur "$file" images ; done
answered Feb 11 at 16:01
BodoBodo
2,048416
2,048416
or initially withfor Q in *;do H=$Q%%.*;zip "$H.zip" images "$Q";done
– Jeff Schaller
Feb 11 at 16:01
That also works, Jeff Schaller. The way that Animate CC publishes canvas files, is that there is only an images folder, if there are bitmaps.
– Susan Forman
Feb 11 at 16:20
add a comment |
or initially withfor Q in *;do H=$Q%%.*;zip "$H.zip" images "$Q";done
– Jeff Schaller
Feb 11 at 16:01
That also works, Jeff Schaller. The way that Animate CC publishes canvas files, is that there is only an images folder, if there are bitmaps.
– Susan Forman
Feb 11 at 16:20
or initially with
for Q in *;do H=$Q%%.*;zip "$H.zip" images "$Q";done– Jeff Schaller
Feb 11 at 16:01
or initially with
for Q in *;do H=$Q%%.*;zip "$H.zip" images "$Q";done– Jeff Schaller
Feb 11 at 16:01
That also works, Jeff Schaller. The way that Animate CC publishes canvas files, is that there is only an images folder, if there are bitmaps.
– Susan Forman
Feb 11 at 16:20
That also works, Jeff Schaller. The way that Animate CC publishes canvas files, is that there is only an images folder, if there are bitmaps.
– Susan Forman
Feb 11 at 16:20
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f499967%2fterminal-command-to-add-a-directory-to-many-existing-zip-files%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
check out the
formatting button to format code separately; it makes it much more readable. Thanks!– Jeff Schaller
Feb 11 at 15:25
1
Try
for file in *.zip ; do zip -ur "$file" images ; done– Bodo
Feb 11 at 15:33
I'm being misled by the introduction in the question; is there anything about matching or paired filenames that are important to you?
– Jeff Schaller
Feb 11 at 15:56
Thank you so much Bodo! That works.
– Susan Forman
Feb 11 at 15:56
Just that the files being zipped initially are an html file that has a js file with the same name.
– Susan Forman
Feb 11 at 15:57