I'm trying to make an applescript that let's me change the desktop picture to a random picture in a folder on my hard drive
tell application "Finder"
set desktopPictures to folder "Path:To:Desktop:Pictures:"
set fileList to name of every file of desktopPictures
set theNum to random number from 1 to (count fileList) with seed ((time of (current date)) * 4)
set fileName to item theNum of fileList
set desktop picture to file fileName in desktopPictures
end tell
So far it works perfectly, the only issue I have is when I connect another monitor, his desktop picture won't change. I tried solving this problem with the following code I found making a web search
tell application "Finder"
set desktopPictures to folder "Path:To:Desktop:Pictures:"
set fileList to name of every file of desktopPictures
set theDesktops to a reference to every desktop
repeat with aDesktop in theDesktops
set theNum to random number from 1 to (count fileList) with seed ((time of (current date)) * 4)
set fileName to item theNum of fileList
set picture of aDesktop to file fileName in desktopPictures
end repeat
end tell
But this code won't compile as I get a syntax error saying:
Expected class name but found property.
With desktop
highlighted on row 4