dougscripts.com

January 31 2012 - 1:27 pm

Sync A Wi-Fi iPhone Follow Up

Several Correspondents have wired in to report that the Sync a Wi-Fi iPhone Once a Day With launchd tip is great and all but how can more than one Wi-Fi device be sync'd? Currently the script only targets a single iPhone or iPad. If you want to sync all connected devices you'll need a different script.

This script should replace the one named “Sync My Device” that was created in the previous article. If you haven't already, create the launchd agent plist from that article.

This will sync every currently connected device (iPod, iPhone, or iPad are each of the kind iPod to AppleScript).

if not checkItunesIsActive() then return

tell application "iTunes"

try

set theSources to (every source whose kind is iPod)

repeat with src in theSources

try

with timeout of 600 seconds

tell src to update

end timeout

end try

end repeat

end try

end tell

to checkItunesIsActive()

tell application id "sevs" to return (exists (some process whose name is "iTunes"))

end checkItunesIsActive

I should say try to sync because if the script runs into any problems it will just quit silently.

If you only want to sync particular devices, you have to include a way to identify them. The best way is with their name. So if "Doug's iPhone", "Doug's iPad", and "Doug's iPod" are connected but I only want to sync the iPhone or iPad they can be detected in the script:

if not checkItunesIsActive() then return

tell application "iTunes"

try

set theSources to (every source whose kind is iPod)

repeat with src in theSources

try

with timeout of 600 seconds

if (get name of src) is in {"Doug's iPhone", "Doug's iPad"} then

tell src to update

end if

end timeout

end try

end repeat

end try

end tell

to checkItunesIsActive()

tell application id "sevs" to return (exists (some process whose name is "iTunes"))

end checkItunesIsActive

The bracketed list contains the names of the devices I want to sync. Edit the script to include the names of your devices as they appear in the iTunes Source list. You can enter one or more names in double-quotes, but each must be separated by a comma. Spelling counts. (And be careful to detect if your device's name contains an apostrophe or a single-quote as a possessive character. Don't confuse them because they are different to AppleScript.)

Follow the instructions for naming and saving the “Sync My Device” script from the previous article.

Site contents © 2001 - 2024 (that's right: 2001) Doug Adams and weblished by Doug Adams. Contact support AT dougscripts DOT com. About.
All rights reserved. Privacy.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc. This site has no direct affiliation with Apple, Inc.
The one who says "it cannot be done" should not be interrupting the one who is doing it.