View Single Post
Old 08-19-2012, 05:09 PM   #7
tbarnum
Registered User
 
Join Date: Aug 2012
Posts: 1
The zip command does seem to include the .DS_Store files even when not using the -S option. If you are zipping a bunch of files and no subdirectories, and you are at the level of the files (current working directory), the following zip will leave out the Dot files:

zip ARCHIVENAME *  -x "\.*"

which get all files at your cwd but Exclude all files that start with a Dot.
The Dot is a special character and so need to be escaped with the "\" .

If you are zipping a Directory with subfolders, and your cwd is at the parent of the Directory and not inside it, and want to remove any Dot files in the main Dir or Subfolders, try the following:

zip -r ARCHIVENAME DIRECTORYNAME  -x "*/\.*"


The last part of "*/\.*" is required instead of just "\.*" because the enclosed files also include the relative Path in the Name ie:
a dot file stored in the subfolder : myfolder1
is expanded as FOLDERNAME/myfolder/.dotfilename
and so the Dotfiles in the Directory or subfolders won't fit the expression "\.*"

To exclude Dotfiles both in your cwd and in subfolders then requires a better Exclude definition, such as two excludes:

zip -r ARCHIVENAME * -x "*/\.*" -x "\.*"


cheers!
tbarnum is offline   Reply With Quote