When I compress files with the built in zip compressor in Mac OSX, it results in an extra folder titled \"__MACOSX\" created in the extracted zip.
Can I adjust my se
When I had this problem I've done it from command line:
zip file.zip uncompressed
EDIT, after many downvotes: I was using this option for some time ago and I don't know where I learnt it, so I can't give you a better explanation. Chris Johnson's answer is correct, but I won't delete mine. As one comment says, it's more accurate to what OP is asking, as it compress without those files, instead of removing them from a compressed file. I find it easier to remember, too.
I'm using this Automator Shell Script to fix it after. It's showing up as contextual menu item (right clicking on any file showing up in Finder).
while read -r p; do
zip -d "$p" __MACOSX/\* || true
zip -d "$p" \*/.DS_Store || true
done
zip -r "$destFileName.zip" "$srcFileName" -x "*/\__MACOSX" -x "*/\.*"
-x "*/\__MACOSX"
: ignore __MACOSX as you mention.-x "*/\.*"
: ignore any hidden file, such as .DS_Store .Also, you can build Automator Service to make it easily to use in Finder. Check link below to see detail if you need.
Github
Do you mean the zip
command-line tool or the Finder's Compress command?
For zip
, you can try the --data-fork
option. If that doesn't do it, you might try --no-extra
, although that seems to ignore other file metadata that might be valuable, like uid/gid and file times.
For the Finder's Compress command, I don't believe there are any options to control its behavior. It's for the simple case.
The other tool, and maybe the one that the Finder actually uses under the hood, is ditto
. With the -c -k
options, it creates zip archives. With this tool, you can experiment with --norsrc
, --noextattr
, --noqtn
, --noacl
and/or simply leave off the --sequesterRsrc
option (which, according to the man page, may be responsible for the __MACOSX
subdirectory). Although, perhaps the absence of --sequesterRsrc
simply means to use AppleDouble format, which would create ._ files all over the place instead of one __MACOSX
directory.
This is how i avoid the __MACOSX
directory when compress files with tar
command:
$ cd dir-you-want-to-archive
$ find . | xargs xattr -l # <- list all files with special xattr attributes
...
./conf/clamav: com.apple.quarantine: 0083;5a9018b1;Safari;9DCAFF33-C7F5-4848-9A87-5E061E5E2D55
./conf/global: com.apple.quarantine: 0083;5a9018b1;Safari;9DCAFF33-C7F5-4848-9A87-5E061E5E2D55
./conf/web_server: com.apple.quarantine: 0083;5a9018b1;Safari;9DCAFF33-C7F5-4848-9A87-5E061E5E2D55
Delete the attribute first:
find . | xargs xattr -d com.apple.quarantine
Run find . | xargs xattr -l
again, make sure no any file has the xattr attribute. then you're good to go:
tar cjvf file.tar.bz2 dir
You can't.
But what you can do is delete those unwanted folders after zipping. Command line zip
takes different arguments where one, the -d
, is for deleting contents based on a regex. So you can use it like this:
zip -d filename.zip __MACOSX/\*