Recently, while trying to upload a zipped project to the WordPress Theme Directory, it was immediately rejected because it contained hidden files. More than once, I tried to create a new zip file, and although I had made sure to delete any hidden files, they kept showing up.
The Finder on the Mac creates hidden
.DS_Store files which are used for keeping track on icons, folder backgrounds etc. These files can create trouble under certain circumstances as, for instance in the above mentioned situation. Also they may look a little suspicious to Windows users to whom the Mac user has tried to send a zipped archive.
(But hey! Please don’t make fun of my Mac: Windows also creates annoying hidden files, for instance
The Command Line to the Rescue
I don’t particularly like the Termnial. The user interface is command based and reminds me a little too much of the old DOS-days. I’m much more of a GUI person.
But the terminal is a problem solver. It easily solves the trouble with the annoying
Firstly, navigate to the folder, in which the files you want to zip, are placed.
(Example: In the folder “foo” you have the folder “bar”, which you want to zip. Navigate to “foo”.)
Now we’re going to zip the folder “bar”. Use the following command:
zip -r bar.zip bar -x "*.DS_Store"
-rrecursively includes all directories underneath the targets we want to zip.
bar.zipis the name of the zip archive we are creating.
baris the target directory we want to zip up.
-x "*.DS_Store"excludes all files whose path ends in the string “.DS_Store”.