Extract .xip files into a specific folder

Antony Raphel picture Antony Raphel · Feb 13, 2017 · Viewed 22.5k times · Source

A XIP file is an analog to zip, but allows for a digital signature to be applied and verified on the receiving system, before the archive is expanded. When a XIP file is opened (by double-clicking), Archive Utility will automatically expand it (but only if the digital signature is intact).

Essentially, a .xip file is just a .zip with a signature to verify that the file has not changed since its creator saved it. This protects from both damage from a disk error and from a third-party tampering with the file.

Does anyone know, how to extract this file, e.g. using Terminal, to a specific folder instead of to the folder where the .xip file resides?

Answer

Geoff Nixon picture Geoff Nixon · Jun 13, 2018

Maybe try:

xip -x [path to .xip file]

That will unpack the archive into your current working directory.

As for extracting into a specific directory, there is not explicitly an option for this, but xip -x will extract into the current working directory. Therefore, cding to where you would like to extract the file should work; if you specifically need to automate this, a script to the effect of:

#!/bin/sh

xipfile="$(cd $(dirname "$1"); pwd -P)/$(basename "$1")" # a portable "realpath"

cd "$2"
xip -x "$xipfile"

Should do the trick I think?