Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

vladimir929

macrumors newbie
Original poster
Oct 22, 2008
12
0
I found an iPod sync applescript on the web and I tried adapting it to automatically sync the iPod every minute. I don't think it works, I was wondering if someone could help me. Thanks!

property minutesBetweensync : 1
tell application "iTunes"
repeat with s in sources
if (kind of s is iPod) then update s
return minutesBetweensync * 60
end repeat
end tell
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
At a quick glance it seems like the return statement might be the problem as that will stop the loop.
 

vladimir929

macrumors newbie
Original poster
Oct 22, 2008
12
0
Thanks!

Ok I removed the return but i still don't think its working. I'm sorry I have just started learning apple script. Thank you so much, you are a big help.

property minutesBetweensync : 1
tell application "iTunes"
repeat with s in sources
if (kind of s is iPod) then update s
-- return minutesBetweensync * 60
end repeat
end tell
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
This should do what you want:
Code:
tell application "iTunes"
    set ipodsource to null
    repeat with s in sources
        if (kind of s is iPod) then
            set ipodsource to s
            exit repeat
        end if
    end repeat

    repeat
        update ipodsource
        delay 60
    end repeat
end tell
First it gets the iPod source, then it goes into an infinite loop. I use a delay to pause for 60 seconds, but the only problem is that when you use the update command, it's asynchronous so that AppleScript doesn't wait until the update command is finished before it continues with the next command. This results in the "delay 60" not being accurate.
 

vladimir929

macrumors newbie
Original poster
Oct 22, 2008
12
0
Thanks!

That script works great. You helped me fix my problem and learn apple script at the same time :D!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.