iLoungeiLounge
  • News
    • Apple
      • AirPods Pro
      • AirPlay
      • Apps
        • Apple Music
      • iCloud
      • iTunes
      • HealthKit
      • HomeKit
      • HomePod
      • iOS 13
      • Apple Pay
      • Apple TV
      • Siri
    • Rumors
    • Humor
    • Technology
      • CES
    • Daily Deals
    • Articles
    • Web Stories
  • iPhone
    • iPhone Accessories
  • iPad
  • iPod
    • iPod Accessories
  • Apple Watch
    • Apple Watch Accessories
  • Mac
    • MacBook Air
    • MacBook Pro
  • Reviews
    • App Reviews
  • How-to
    • Ask iLounge
Font ResizerAa
iLoungeiLounge
Font ResizerAa
Search
  • News
    • Apple
    • Rumors
    • Humor
    • Technology
    • Daily Deals
    • Articles
    • Web Stories
  • iPhone
    • iPhone Accessories
  • iPad
  • iPod
    • iPod Accessories
  • Apple Watch
    • Apple Watch Accessories
  • Mac
    • MacBook Air
    • MacBook Pro
  • Reviews
    • App Reviews
  • How-to
    • Ask iLounge
Follow US

News › Apple TV

Apple TVAsk iLoungeiTunesMac

Automatically Refreshing Photos in iTunes for Apple TV

Last updated: May 16, 2021 4:28 pm UTC
By Jesse Hollington
Automatically Refreshing Photos in iTunes for Apple TV

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.


– Patrick

Automatically Refreshing Photos in iTunes for Apple TV

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.

 

Automatically Refreshing Photos in iTunes for Apple TV

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”.

 

Automatically Refreshing Photos in iTunes for Apple TV

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…


 

Automatically Refreshing Photos in iTunes for Apple TV

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.


Latest News
AirPods Max 2 is $20 off
AirPods Max 2 is $20 off
1 Min Read
Apple and John Giannandrea Part Ways
Apple and John Giannandrea Part Ways
1 Min Read
Huawei Unveils Foldable Device
Huawei Unveils Foldable Device
1 Min Read
Mass Production for iPhone Fold Delayed
Mass Production for iPhone Fold Delayed
1 Min Read
AirPods Pro 3 is $49 off
AirPods Pro 3 is $49 off
1 Min Read
Valve Announces Stream Link App For Vision Pro Headset
Valve Announces Stream Link App For Vision Pro Headset
1 Min Read
Apple Using Smart Adhesive for Foldable iPhone
Apple Using Smart Adhesive for Foldable iPhone
1 Min Read
Apple Creating Different Styles for Smart Glasses
Apple Creating Different Styles for Smart Glasses
1 Min Read
14-inch M5 Pro MacBook Pro 24GB 1TB Is $149 Off
14-inch M5 Pro MacBook Pro 24GB 1TB Is $149 Off
1 Min Read
Shipment For Apple Mac Increases
Shipment For Apple Mac Increases
1 Min Read
Developer Integrates Mac OS X Cheetah for the Nintendo Wii
Developer Integrates Mac OS X Cheetah for the Nintendo Wii
1 Min Read
New Subscription Added by OpenAI
New Subscription Added by OpenAI
1 Min Read

iLounge logo

iLounge is an independent resource for all things iPod, iPhone, iPad, and beyond. iPod, iPhone, iPad, iTunes, Apple TV, and the Apple logo are trademarks of Apple Inc.

This website is not affiliated with Apple Inc.
iLounge © 2001 - 2025. All Rights Reserved.
  • Contact Us
  • Submit News
  • About Us
  • Forums
  • Privacy Policy
  • Terms Of Use
Welcome Back!

Sign in to your account

Lost your password?