Created
September 4, 2010 09:58
-
-
Save rngtng/565059 to your computer and use it in GitHub Desktop.
shell/apple script to sich iTunes library easily
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
tell application "System Events" | |
set runs to count (every process whose name is "iTunes") | |
end tell | |
set lib to do shell script "ls -l ~/Music | grep -i '\\->.*Music/iTunes' | sed 's/^.*iTunes-//g'" | |
set question to display dialog "iTunes is using '" & lib & "'. Switch to:" buttons {"external", "internal", "swing"} default button lib with icon 2 with title "Choose witch Library to use" | |
set new_lib to button returned of question | |
if new_lib is equal to lib then | |
return | |
end if | |
if runs is equal to 1 then | |
tell application "iTunes" | |
quit | |
delay 5 | |
end tell | |
end if | |
do shell script "rm ~/Music/iTunes" | |
do shell script "ln -s ~/Music/iTunes-" & new_lib & " ~/Music/iTunes" | |
tell application "iTunes" | |
activate | |
end |
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 | |
TEST=$(ps -x |grep "/iTunes " |grep -v grep |wc -l) | |
if [[ $TEST -ne 0 ]] | |
then | |
echo "iTunes is running. Please quit iTunes first" | |
exit | |
fi | |
LIB="`ls -l ~/Music | grep -i '\->.*Music/iTunes' | sed 's/^.*iTunes-//g'`" | |
if [ "$LIB" == "internal" ] | |
then | |
rm ~/Music/iTunes | |
ln -s ~/Music/iTunes-external ~/Music/iTunes | |
echo "External lib is being used" | |
else | |
rm ~/Music/iTunes | |
ln -s ~/Music/iTunes-internal ~/Music/iTunes | |
echo "Internal lib is being used" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment