Automatically Refreshing Photos in iTunes for Apple TV
Ask iLounge offers readers the opportunity to get answers to their iPod-, iPhone-, iPad-, iTunes-, or Apple TV-related questions from a member of the iLounge editorial team. We'll answer several questions here each week, and of course, you can always get help with more immediate concerns from the iLounge Discussion Forums. Submit your questions for consideration using our Ask iLounge Submit Form. We reserve the right to edit questions for grammar, spelling, and length.
Q: I found your article last week on Refreshing Photo Albums on the Apple TV and I’m in a similar situation. I’m a Mac user, but I prefer to use folders for my Apple TV as I want to be able to quickly add new pictures without having to go through iPhoto. I also leave my iMac and iTunes on all of the time, which I gather from your article is why I don’t see new photos showing up. Is there some way to automatically refresh my photos through AppleScript or something that would be easier than going in and messing with the sharing settings whenever I add something to my photo folders? I’ve seen some tips on setting up iTunes to restart automatically on a schedule, but I don’t want to do that because I’m often downloading new stuff or using the Apple TV to watch or listen to something from iTunes.
A: This actually is possible via AppleScript; it’s a bit kludgy since it uses a feature known as “GUI Scripting” which basically just selects the normal iTunes options on your behalf, but it gets the job done.
Unfortunately, none of the photo sharing features in iTunes are exposed directly to AppleScript, so we’re forced to resort to manipulating iTunes controls directly. To allow AppleScript to do this on your behalf, it is first necessary to go into your OS X System Preferences application and select the Enable access for assistive devices option under your Universal Access settings.
The option allows AppleScript to directly access user interface elements in applications on your Mac. Once you’ve done this, an AppleScript such as the following can be used to refresh your photo folders in iTunes simply by going through the steps of opening the Choose Photos to Share dialog, changing some options and then closing that window afterwards.
tell application "System Events" if my appIsRunning("iTunes") then tell process "iTunes" # Open the Photo Sharing settings from the "Advanced" menu click menu item "Choose Photos to Share…" of menu ¬ "Advanced" of menu bar item "Advanced" of menu bar 1 # Toggle the status of the "Include videos" checkbox to force a change click checkbox "Include videos" of scroll area 1 of window "Photo Sharing Preferences" click button "Apply" of window "Photo Sharing Preferences" # Toggle the status of the "Include videos" checkbox again to return it to its original setting click checkbox "Include videos" of scroll area 1 of window "Photo Sharing Preferences" click button "Apply" of window "Photo Sharing Preferences" # Close the Photo Sharing settings window click (first button of window "Photo Sharing Preferences" whose subrole is "AXCloseButton") end tell end if end tell on appIsRunning(appname) tell application "System Events" to (name of processes) contains appname end appIsRunning
The in-line comments in the script above describe what it does. To summarize, we’re confirming that iTunes is running, and if so simply toggling the Include videos option to force iTunes to re-read the photo collection. The Include videos option is toggled a second time to return it to its original setting before closing the window. Note that if you don’t normally include videos in your photo folders anyway, you can remove this second section as it doesn’t matter whether the Include videos option is set or not.
If iTunes is not running in this case, the script does nothing, since starting up iTunes would refresh the photo folders anyway, effectively rendering the remainder of the script redundant.
To use the script, you can simply choose to run it manually, saving it in AppleScript editor as an “Application” that you can then put somewhere convenient—such as on your Desktop or in your Dock—and simply run by clicking on it.
Alternatively, you could set the script up to run either on a scheduled basis or as a Folder Action that is triggered whenever you make a change to one of your photo folders.
Setting your script up to run on a schedule is most easily and transparently done with the third-party utility Lingon ($3), however it is also possible to schedule it as a recurring iCal event with an alert type of “Run Script”.
Another way to approach this is to setup the script to run as a Folder Action against whatever folders you normally use for photos. This first requires a very slight modification to the above AppleScript to add the appropriate Folder Action handlers, as follows:
At the top of the script, add…
on adding folder items to this_folder after receiving added_items tell application "System Events" if my appIsRunning("iTunes") then tell process "iTunes" … …
…and at the bottom, insert:
… … end tell end adding folder items to on appIsRunning(appname) tell application "System Events" to (name of processes) contains appname end appIsRunning
You then need to save the script in your ~/Library/Scripts/Folder Action Scripts folder and you should then be able to associate the script with the appropriate folder by right-clicking on the folder in Finder and choosing Services, Folder Actions Setup…
Note that Folder Actions do not include sub-folders by default, so you will need to associate the script with each folder where you plan to add photos on a regular basis. Further, the script modifications above will only be initiated when adding new items to your Photos folder; if you want to have the script also run when removing items, you will need to add another copy of the main code block with the handler on removing folder items from this_folder after losing removed_items. This is left as an exercise for the reader, or you can simply download a complete version of the script ready to be used as a Folder Action.
In regard to automating the script, it’s important to note that since it uses GUI scripting and is therefore interacting directly with the active user interface, it may be inconvenient to have it run at times when you may otherwise be working. It is recommended to either run it on a schedule based on when you’re unlikely to be using the computer, or, if running it as a Folder Action, be sure to wait two or three seconds after adding or removing files for the iTunes window to pop-up and disappear before continuing whatever else you’re doing.
It’s also important to note that this script was designed for iTunes 10.6.3 specifically. It is very likely to break or require modifications in future versions of iTunes, particularly if Apple decides to reorganize the photo sharing procedures. Of course, ideally we hope that Apple fixes the photo folder refresh issue in a future version of iTunes, thereby making such workarounds completely unnecessary.
The most asked question at iLounge.com:
Converting DVDs, web video, TV shows and more:
Converting DVDs, web video, TV shows and more:
Converting DVDs, web video, TV shows and more:
Find more answers in the latest publications in our Library. Free downloads developed by the editors of iLounge!
Ask iLounge Archives:
1-24-14: Viewing only downloaded iTunes Match tracks
1-22-14: Splitting purchased content between two iPads
12-13-13: Non-Bluetooth Lightning dock speakers
12-11-13: Shared Apple ID and switching away from iPhone
12-6-13: Syncing multiple iCloud data with a family Mac
- Viewing only downloaded iTunes Match tracks
- Splitting purchased content between two iPads
- Non-Bluetooth Lightning dock speakers
- Shared Apple ID and switching away from iPhone
- Syncing multiple iCloud data with a family Mac
- iMessages come in from email address instead of phone number
If you have a comment, news tip, advertising inquiry, or coverage request, a question about iPods/iPhones/iPad or accessories, or if you sell or market iPod/iPhone/iPad products or services, read iLounge's Comments + Questions policies before posting, and fully identify yourself if you do. We will delete comments containing advertising, astroturfing, trolling, personal attacks, offensive language, or other objectionable content, then ban and/or publicly identify violators.
- Happy Thanksgiving 2014 from iLounge!
- Apple highlights more Apple Watch info
- Verizon sponsoring ad-free listening to all U.S. iTunes Radio users
- Microsoft, Yahoo hope to replace Google for Safari default search?
- T-Mobile required to fully disclose throttled data speeds
- Steve Jobs biopic picked up by Universal, Fassbender to star
- Handbrake updated to 0.10, adds new encoders + more
- Report: ‘Deep Organizational Issues’ at Apple affecting iCloud progress
- Apple announces Product(RED) Gift Cards for Black Friday
- Apple unveils Product(RED) apps for World AIDS Day 2014
- Verus Case Damda Slide for iPhone 6 Plus
- Heckler Design @Rest Stand for iPad (2014)
- Kerf Case Wood Cases for iPhone 6 and iPhone 6 Plus
- Urban Armor Gear Folio for iPhone 6 Plus
- ZeroChroma FluxStand-Compatible Car Vent Mount + Reflective Armband
- Griffin Slim Folio and Survivor All-Terrain for iPad Air 2
- ZeroChroma Slide-Mount Combo Pack for iPad Folio-Slide Cases
- G-Project G-Go Outdoor Wireless Speaker (2014)
- SteelSeries Stratus XL Gaming Controller
- Belkin/Jarden Mr. Coffee 10-Cup Smart Coffeemaker
- Instant Expert: Secrets & Features of iOS 8.1
- An Easy Guide To Setting Up + Using Apple Pay In iOS 8.1
- Ten Things You Didn’t Know About iPad Air 2 + iPad mini 3
- Mind The Gap: What’s iPad’s Role In An iPhone 6 (Plus) World?
- Editorial: Why I Switched To T-Mobile (And You Might, Too)
- The Early Guide To Apple Watch Apps
- iLounge’s Top iPhone 6 + iPhone 6 Plus Case Picks (Fall 2014)
- Instant Expert: Secrets & Features of iOS 8.0
- Multi-Editorial: On Apple’s iPhone 6, iPhone 6 Plus + Apple Watch
- What’s New In Apple TV 7.0