Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

With zip foo.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 stackoverflow.com Jul 7 '13 at 23:01

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

1 Answer 1

up vote 1 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

 
discard

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