Last active
March 3, 2018 16:28
-
-
Save nriley/33643194fa7da129dc5e67e621c44478 to your computer and use it in GitHub Desktop.
Script to archive a macOS application.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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