AppleScript iTunes - Change Preferences

Discussion in 'Mac Programming' started by ApolloX, Jul 18, 2008.

  1. ApolloX macrumors newbie

    Joined:
    Feb 1, 2007
    #1
    This question is about the "iTunes -> Preferences -> Advanced -> Copy files to iTunes Music folder when adding to library". Normally, I like to keep this setting checked for songs, but recently I wrote an applescript that adds video files stored on a network folder to my iTunes library. Because I don't want to actually download these files to my mac, I had to change the preference to be unchecked anytime the script runs.

    Desired Solution: Some way I can keep the copy to libary setting checked most of the time, except when I'm copying video files.

    Idea 1: Keep the button copy to libary setting checked but have the script tell iTunes to ignore the copy. Something like "add x to Library without copying"

    Idea 2: Have the script turn the copy to library setting off before it begins and back on after it completes. Would need syntax for an applescript to modify this preference.

    Anyone know the commands to make either of these ideas work?
     
  2. jschwar macrumors newbie

    Joined:
    Sep 1, 2014
    #2
    Hey there. I stumbled onto this thread looking for a solution to the exact same problem! I have been trying (and failing miserably) to build an applescipt myself to complete this exact task. Have you had any luck?

    Would you mind sharing any code you have tried? I am seeming to fail at being able to click the "advanced" icon in the popup window. This is my sad attempt after a painstaking few hours:

    tell application "iTunes" to activate

    tell application "System Events"
    keystroke "," using command down
    --set current panel of window prefences to Advanced Preferences panel
    --click checkbox "Copy files to iTunes Media folder when adding to library"
    end tell
     
  3. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #3
    Try this :

    Code:
    tell application "iTunes" to activate
    
    tell application "System Events"
    	tell process "iTunes"
    		keystroke "," using command down
    		delay 1
    		click button "Advanced" of toolbar 1 of window 1 --"General Preferences"
    		-- Check the checkbox if it is checked!
    		if value of checkbox "Copy files to iTunes Media folder when adding to library" of group 1 of window "Advanced Preferences" is 0 then
    			click checkbox "Copy files to iTunes Media folder when adding to library" of group 1 of window "Advanced Preferences"
    		end if
    		click button "OK" of window "Advanced Preferences"
    	end tell
    end tell
     
  4. jschwar macrumors newbie

    Joined:
    Sep 1, 2014
    #4
    WOW thank you so much! that totally worked!
     

Share This Page