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).
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("__*.*", ".*.*")
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.
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.
Keka has option to ignore MacOS files in the Zip.
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.
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.
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.
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.
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.