MacOS – How to remove __MACOSX folder in a list of zip files (not a single zip file)

command linemacbook promacoszip

I know I can remove __MACOSX in a zip file by:

sudo zip -d bg1.zip "__MACOSX*"

but I want to remove it in all zip files, I tried

sudo zip -d *.zip "__MACOSX*"

but it says

zip warning: name not matched: __MACOSX*

zip error: Nothing to do! (bg1.zip)

and seems stop from processing next file. How can I remove all __MACOSX in a list of zip files?

Best Answer

If all .zip files are in the same directory, cd to that directory and use:

for f in *.zip; do zip -d "$f" "__MACOSX*"; done