I only just came across this thread. I have written the following into a file, to randomly select a desktop background from my folder full of desktop backgrounds:
--
#!/usr/bin/perl
$background_path="/Volumes/Icarus/Desktop Backgrounds";
$raw=`find "$background_path" \\( \\( -name "*.jpg" -or -name "*.jpeg" \\) -or -name "*.tiff" \\) -print`;
@the_files=split(/\n/,$raw);
$the_number=1+ int rand scalar @the_files;
$the_file=join("\%20",split(/\s+/,@the_files[$the_number]));
`defaults write com.apple.finder DesktopViewOptions -dict-add BackgroundPictureURL "file://localhost$the_file"`;
--
I'm only just learning Perl, so I am not sure if array lengths start at 1 or 0. For me, this will only come up 1/250th percent of the time, so I like those odds. Anyway, one should need only to change the $background_path to get this to work elsewhere.
Now, personally I run a cron job that changes my desktop background every couple of hours. Right now, I'd have to log in and out every couple of hours to appreciate it, though. Has anyone found a way to get the Finder to refresh itself? I know applications can do it, but can Perl scripts?