The Computer Oracle

Compressing folders on a mac, without the .DS_Store

Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Lost Civilization

--

Chapters
00:00 Question
00:43 Accepted answer (Score 131)
01:55 Answer 2 (Score 7)
03:05 Answer 3 (Score 4)
03:42 Answer 4 (Score 3)
04:27 Thank you

--

Full question
https://superuser.com/questions/198569/c...

Answer 1 links:
[image]: https://i.stack.imgur.com/pUcRR.png
[image]: https://i.stack.imgur.com/PMCfm.png

Answer 2 links:
[whaley's answer]: https://superuser.com/a/198593/393349

Answer 3 links:
[FolderWasher]: http://www.addictivetips.com/windows-tip.../
[action created]: http://www.apple.com/downloads/macosx/au...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#macos #compression #zip

#avk47



ACCEPTED ANSWER

Score 132


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.




ANSWER 2

Score 4


If you've already created the zip archive (or want a simple way of removing .DS_Store post zip creation), this will remove all .DS_Store files at any path in the zip archive:

zip -d archive.zip "*/*.DS_Store"

whaley's answer is still definitely the best, because it can be aliased and forgotten about. In my case, I created the zip from the Archive Utility, then realized I should delete these.




ANSWER 3

Score 3


I don't think there's a way to do it by default, but there's two ways I can think of to achieve what you want.

First off, I found a free app called FolderWasher. Drop the folder on the app and it'll remove the .DS_Store files and zip it for you.

Alternatively (and potentially better than 3rd party software) you can use Automator to clean the archive after creation. There is actually already an action created for this. That's only one extra step, and you can drag the action to Finder so it's easy to find.




ANSWER 4

Score 2


Open Terminal (/Applications/Utilies/Terminal.app) and run the following command to show hidden files:

defaults write com.apple.finder AppleShowAllFiles TRUE && killall Finder

To hide the hidden files simply run:

defaults write com.apple.finder AppleShowAllFiles FALSE && killall Finder

You can delete .DS_Store files just like any other files without causing any harm to your directory. As stated on wikipedia, "DS_Store (Desktop Services Store) is a hidden file created by Apple Inc.'s Mac OS X operating system to store custom attributes of a folder such as the position of icons or the choice of a background image."