Creating the zip file in format as same as Finder

Finder has a function create the zip file from the file or the folder. This zip file is different from the zip file Windows creates. This article says this zip file as Finder style zip file.

You can create this zip file from the terminal and the shell script. You can create it in the automated script.

This article explains that how to create the Finder style zip file and how to expand it.

Creating the Finder style zip file

You can create the Finder style zip file with ditto.

$ ditto -c -k --sequesterRsrc --keepParent Test

Above line create the file by archiving the Test folder.

-c option specify creates the archive, -k option specify compress with PKZip, --sequesterRsrc option create the __MACOSX folder to store the resource fork and the HFS meta data.

Specify only one file

If you create the zip file with only one file, --keepParent option may be an obstacle. For example, following line create the zip file by archiving the 123.jpg file in the desktop.

$ ditto -c -k --sequesterRsrc --keepParent 123.jpg

Expand it, the Desktop folder will be created and the 123.jpg file is put in the created folder. Redundant folder will be created.

--keepParent option put the Desktop folder which is a parent folder of the 123.jpg file.

It may be better to create without --keepParent option if you create the zip file with only one file.

However, this is not good with the application package. The application package is looked like a simple file in the Finder, but it is a folder. The --keepParent option is need to archive the application package.

Expanding the zip file

The ditto can expand the zip file. Following line expand the Finder style zip file:

$ ditto -x -k ./

Above line expand the file into the current directory. If you replace ./ with the destination folder, ditto will create the destination folder and expand into it.

The -x option expand the archive, and the -k option indicate that the format of the zip file is the PKZip format.

Author Profile

Akira HayashiA professional developer specializing in macOS Apps, iOS Apps, SDKs and middleware development.
Representative of RK Kaihatsu. I am a professional developer specializing in macOS Apps, iOS Apps, SDKs and middleware development. I often use ObjC, Swift and C++. Based on development experience, I provide e-learning contents, technical books and technical guidance. I am also a technical seminar instructor, in-house training instructor, and administrative / local goverment staff training instructor.
Get the Latest News !
>Programming Tips From Software Engineer

Programming Tips From Software Engineer

Technical News, Documents and Tips.