Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PREREQUISITE: Install platform-tools and https://github.com/google/adb-sync
#!/bin/bash
set -eu
: ${ITUNES_MEDIA_DIR:="${HOME}/Music/iTunes/iTunes Media"}
: ${DST_MUSIC_DIR:=/storage/0000-0000/Music}
usage() {
cat <<EOT
Usage: $0 [-x]
Options:
-x NOT dryrun
Environments:
ITUNES_MEDIA_DIR="${ITUNES_MEDIA_DIR}"
DST_MUSIC_DIR="${DST_MUSIC_DIR}"
EOT
}
abort() { >&2 echo "ERROR: $*"; exit 1; }
run() { echo "RUN: $*"; "$@"; }
opt_nargs=0
opt_dryrun=true
while (($# > 0)); do
case "$1" in
-h | --help ) usage; exit 1;;
-x ) opt_dryrun=false;;
-* ) abort "unknown option: $1";;
* )
case $((++opt_nargs)) in
* ) abort 'too many arguments';;
esac
;;
esac
shift
done
sync_opts=(-n)
if $opt_dryrun; then
sync_opts=("${sync_opts[@]}" --dry-run)
fi
run adb-sync "${sync_opts[@]}" "${ITUNES_MEDIA_DIR}/Music/" "${DST_MUSIC_DIR}/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.