Zip without including __MACOSX

Mac creates the file __MacOSX in every zip file but my zip file is for distribution on all platforms and although the file is hidden on Mac it is visible for Windows users and they get very confused by it.
I know I can exclude it by using Zip in terminal but I want to use FolderItem.zip without including this file (and .DS_Store).

1 Like

Try man zip

The instructions are in there.

Currently I think that there isn’t such option, you should create a feature request for more parameters, like a: exclude() As String. An array of masks of items to exclude. Then you could use one as Array("__*.*", ".*.*")

1 Like

I can’t find anything like that in Documentation relating to Folderitem.
Can you post an example code please?

I guess he was focused on the title of your request and missed your detail. Been there, done that.

2 Likes

It looks like, due to the way FolderItem.Zip is implemented, you won’t be able to exclude the .DS_Store and __MACOSX files without some pretty bad workarounds.

Are plugins an option for you? The way both Einhugur and MBS work, you would choose exactly what items to pack into the zip. You could easily skip / ignore specific files with plugins.

I unzip using MBS plugins and dont extract the files that begin with .

I also delete the folder _MACOSX

But if the zip file is a ‘create once, ship many’ support file,

Unzip it on Windows

Delete the _MACOSX folder

Right click on the folder, and zip it up on Windows, then ship that version.

Or ‘explore’ the zip file using WinZip or 7Zip or similar, and remove the folder that way.

I’ve been using YemuZip for this. Very simple and easy.

For getting rid of the .DS_Store, at least, prior to zipping you can do

xattr -rc /path/to/build/folder

“Instructions to modify the original source folder” was one of the things I intentionally chose not to describe.

1 Like

Keka has option to ignore MacOS files in the Zip.

2 Likes

Do you use MBS Xojo Plugins?

Then you could use ArchiveWriterMBS class to write a zip file and control what goes in. Or the older ZipMBS class.

1 Like

If someone want to go the shell route, better use Greg’s approach, the “zip” command is macOS native, and to do that, is something like:

zip -r /path/to/my_folders_zipped.zip /path/to/root_folder/ -x '**/__MACOSX' -x '**/.DS_Store'

But yes, adding more FolderItem.Zip() options is a must. Someone should think an useful set of basic options to include in the parameters.

1 Like

My app allows users to create the zip file for email or distribution (to any platform). I don’t want to give them extra steps before they do this. They may not even have Windows OS.

1 Like

Thought you were making one and shipping it to all

After using FolderItem.zip to create your archive, you can use zip from a shell script with the -d option to remove files from the archive, like this:

zip -d your_archive.zip ./__MACOSX* \*.DS_Store

I use this exact command in an Automator quick action to clean zip files from the Finder. Works well.

1 Like

Why 2 steps? If we need to call zip, call it once, and do the entire job writing only.
It could be better if FolderItem.zip() could do the entire job, but as it can’t
 shell(zip) once.