Skip to content

Instantly share code, notes, and snippets.

@nriley
Last active March 3, 2018 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nriley/33643194fa7da129dc5e67e621c44478 to your computer and use it in GitHub Desktop.
Save nriley/33643194fa7da129dc5e67e621c44478 to your computer and use it in GitHub Desktop.
Script to archive a macOS application.
#!/bin/zsh -ef
set -x
app="$1"
# https://stackoverflow.com/a/1665662/6372
space_version=$(/usr/local/bin/launch -f "$1" |
sed -e 's/^ version: \(.*\) \[.*/ \1/; t' \
-e 's/^ version: \(.*\)/ \1/; t' \
-e 'd')
year=${${(s/-/)$(/usr/bin/mdls -raw -name kMDItemContentCreationDate "$1")}[1]}
archive="/Volumes/BanjoArchive/Software/$year/${app:t:r}${space_version}.zip"
/usr/bin/ditto -kc --keepParent "$app" "$archive"
/usr/bin/open -R "$archive"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment