Last active
February 16, 2020 22:55
-
-
Save pyohei/2a5fe506be29e07b89428198268be4dc to your computer and use it in GitHub Desktop.
Copy iTunes Music into iCloud drive directory.
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/sh | |
# | |
# Copy iTunes Music data into iCloud drive. | |
# This script placed on https://gist.github.com/pyohei/2a5fe506be29e07b89428198268be4dc | |
# If you modify, you reflect it on the upper gist!! | |
# | |
# Licence: MIT | |
ICLOUD_DIR="/Users/${USER}/Library/Mobile Documents/com~apple~CloudDocs" | |
ITUNES_MUSIC_DIR="/Users/${USER}/Music/iTunes/iTunes Media/Music" | |
RSYNC_PATH=/usr/local/bin/rsync | |
# If you want to test this script, you should add `-n` option. | |
$RSYNC_PATH -v -a --checksum "${ITUNES_MUSIC_DIR}" "${ICLOUD_DIR}" > /var/tmp/iTunesCopy.txt | |
osascript -e ' | |
display notification "iTunesのMusic同期完了しました。" with title "Script" | |
' | |
# Get Result count | |
RESULT_COUNT=`grep Music /var/tmp/iTunesCopy.txt | wc -l` | |
# Send notification | |
if [ ! -z "${ITUNES_FINISH_NOTIFICATION_URL}" ]; then | |
curl -X POST -H "Content-Type: application/json" -d "{\"value1\":\"${RESULT_COUNT}\"}" ${ITUNES_FINISH_NOTIFICATION_URL} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment