Skip to content

Instantly share code, notes, and snippets.

@bgerstle
Created May 27, 2015 14:23
Show Gist options
  • Save bgerstle/0c1d1ba875644a116c7c to your computer and use it in GitHub Desktop.
Save bgerstle/0c1d1ba875644a116c7c to your computer and use it in GitHub Desktop.
Extract the "Documents" folder from one or more "xcappdata" archives into a given directory.
#! /usr/bin/env bash
set -e
declare -r OUTPUT_DIR="$1"
shift
if [[ "$OUTPUT_DIR" == "" ]]; then
echo "Need to specify an output directory as the first argument"
exit 1
fi
mkdir -p "$OUTPUT_DIR"
function export_xcappdata() {
local path="$1"
local name="$(basename "${path}" | sed 's:\.xcappdata::')"
local outfile="${name}.zip"
local src="${path}/AppData/Documents"
echo "Zipping ${src} to ${OUTPUT_DIR}${outfile}"
pushd "$src" > /dev/null
zip -r "${outfile}" .
popd > /dev/null
mv "${src}/${outfile}" "${OUTPUT_DIR}"
}
for f do
export_xcappdata "$f"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment