If you do not mind jumping down in to terminal, then this is pretty darn easy. If you are in /Users/username
, which is your $HOME directory and there is a subdirectory named foo that you want to zip but ignore all .DS_Store files, then do the following:
zip -r foo.zip foo -x "*.DS_Store"
To interpret this, we are running the zip executable with the following parameters/arguments:
-r
for recursively including all directories underneath the targets we want to zip.
foo.zip
is the name of the zip archive we are creating
foo
is the target directory we want to zip up
-x "*.DS_Store"
excludes all files whose path ends in the string ".DS_Store"
No goofy third party applications needed nor do you need to trash your .DS_Store files at all - just rely on all of the unix tool goodness built right in to OSX / Darwin.
1This is perfect thanks. Out of interest, how would I exclude multi path endings? Something like zip -r foo.zip foo -x "*.DS_Store, *.svn" ? – danixd – 2010-10-12T14:10:19.960
5Use the -x argument twice:
zip -r foo.zip foo -x *.DS_Store -x *.svn*
– whaley – 2010-10-12T14:50:40.187How do you exclude the Icon-files OSX creates for custom folder icons? They have a newline or something like that at the end of the filename. – Daniel Beck – 2010-10-12T17:42:38.140
I have no clue what those filenames look like so I can't give any real guidance here. – whaley – 2010-10-12T18:36:53.087
ls
saysIcon?
, but I think it's ASCII0x0A
at the end. If you have an OS X system, copy & paste an icon from one file info dialog to another (select the icon on the top left andCmd-C
, then on a folder info dialog the same withCmd-V
). Then the file is created within the folder. – Daniel Beck – 2010-10-13T10:54:54.787As long as this file is not excluded, your solution might be "purer" than the others using third-party utilities etc., but inferior. And I also would like be able to trash one-trick ponies like CleanArchiver. This is why I ask. – Daniel Beck – 2010-10-13T10:56:21.727
1@Daniel Beck - so keep using CleanArchiver and don't hijack the comment section of someone else's question and accepted answer to the call the solution inferior when it obviously works for the original poster? The answer to your question, amazingly enough, is
-x 'Icon?'
. The "?" character in a file globbing pattern means "match a single wildcard character", so it will match irrespective of what the "?" really is. You can exclude ad-hoc files of any kind by just appending more -x arguments.zip
is very flexible. What do you suppose these third party utils really use behind the scenes? – whaley – 2010-10-13T13:23:44.697I am sure other tools use
– Daniel Beck – 2010-10-13T13:56:42.477zip
or something comparable internally, which is why I asked in the first place -- the OP already has made up his mind; I merely wanted to provide additional information for others. Since it's very closely related to the question and your answer, my comments belong here. Thanks for the hint with?
; will have to figure out how to unexcludeIcons
, but it's a start.