Skip to content

Instantly share code, notes, and snippets.

@rngtng
Created September 4, 2010 09:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rngtng/565059 to your computer and use it in GitHub Desktop.
Save rngtng/565059 to your computer and use it in GitHub Desktop.
shell/apple script to sich iTunes library easily
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
#!/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