I have a script that a friend wrote for me when I had OS 9 that I want to convert to OS X. Unfortunately, I have not been able to make it work yet. I keep getting an error saying “Finder got an error: Can’t get every file of folder “Additional Desktop Pictures” of startup disk.” However, the system preferences have no problem reading all the pictures and using any of them for my desktop picture.
Here is the original script for OS 9 –
set picturefolder to "Additional Desktop Pictures"
tell application "Finder"
set filecount to number of files in folder "Additional Desktop Pictures" of startup disk
set pickone to random number from 1 to filecount
set thepicture to name of file index pickone of folder picturefolder of startup disk
end tell
tell application "Appearance"
activate
set scroll bar arrow style to single
set picture file of monitor 1 to alias ("Stacey's hd:" & picturefolder & ":" & thepicture)
set picture positioning of monitor 1 to automatic
quit
--set picture file to file ("Stacey's hd:Additional Desktop Pictures:" & thepicture) as alias
end tell
and here is the script that another friend has helped me generate… unfortunately, it keeps getting the error about not being able to get all the files of the folder –
set picturefolder to "Additional Desktop Pictures"
tell application "Finder"
set filecount to number of files in folder "Additional Desktop Pictures" of startup disk
set pickone to random number from 1 to filecount
set thepicture to name of file index pickone of folder picturefolder of startup disk
end tell
tell application "System Events"
tell process "System Preferences"
activate
set contents of picture file of monitor to "Buddykat:" & home & "Additional Desktop Pictures:" & thepicture
set picture positioning of monitor to automatic
quit
--set picture file to contents of file ("Buddykat:" & home & "Additional Desktop Pictures:" & thepicture)
end tell
end tell
Where is the “Additional Desktop Pictures” folder located? You can answer this question easily by running this script (choose the folder in question) and then doing a paste into the reply (the script will send the folder’s path to the clipboard).
Edited: I just re-read your post and saw that your folder is not on the desktop, don’t know what I was looking at.
So now that you know your source folder is on the desktop, this should work (although there is no guarantee since your original code seems to compile to variables on my system, not application constants in the System Preferences block):
Now the problem it comes up with is that it can’t get every file in the folder… any suggestions? I have 213 files in the folder, but System Preferences has no problems with it… just the script.
Sorry, been having issues with my computer… it keeps crashing. So now I’m in the process of backing everything up so I can take it in next weekend and find out what’s wrong with it. I will let you know as soon as I can test that new script.