Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to remove __MACOSX directory in zip files that are made by Mac.

With zip -qd "__MACOSX/*" works well.

Then I wrote like following. for file in "*.zip"; do zip $file -qd "__MACOSX/*"; done

But this script have effect only first zip file in the directory.

Next I try to use "find" and "xargs". But it didn't worked at all. find . -name "*.zip" -print0 | xargs -0 zip -qd "__MACOSX/*"

How can I write a script that removes all __MACOSX directory in multiple zip files.

share|improve this question

migrated from Jul 7 '13 at 23:01

This question came from our site for professional and enthusiast programmers.

up vote 3 down vote accepted

You want to quote the $file in the command, but not the glob in the for:

for file in *.zip; do zip "$file" -qd "__MACOSX/*"; done
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.