Desktop Slideshow

Run this script and choose a folder full of images for a very nifty slide show.

OS version: OS X

tell application "Finder"
	activate
	set picturefolder to (choose folder with prompt "Locate a folder full of images for slide show:") as string
	set desktop_picture_old to (desktop picture) as alias
	set filecount to number of files in folder picturefolder
	try
		repeat with i from 1 to filecount
			try
				set desktop picture to file index i of folder picturefolder
				delay 10
			end try
		end repeat
	on error --so if you cancel out of the script
		set desktop picture to desktop_picture_old
	end try
	set desktop picture to desktop_picture_old
end tell

I tried little to improve the script:


set picturesFolder to path to pictures folder -- or other folder with images

-- HIDE all application's windows to see only slideshow on the screen
tell application "System Events" to set visible of every application process to false

tell application "Finder"
	set picturesFolder to duplicate picturesFolder
	set picturesFolder to (move picturesFolder to (path to temporary items from user domain) replacing yes)
end tell

tell application "Finder"
	set theImageFiles to ((every file of picturesFolder) whose (kind contains "image")) as alias list
	set desktop_picture_old to (get desktop picture)
	set desktopBounds to bounds of window of desktop
	set desktopWidth to (item 3 of desktopBounds) - (item 1 of desktopBounds)
	set desktopHeight to (item 4 of desktopBounds) - (item 2 of desktopBounds)
end tell

repeat with anImageFile in theImageFiles
	tell application "Image Events"
		launch
		set anImage to open anImageFile
		pad anImage to dimensions {desktopWidth, desktopHeight}
		save anImage with icon
	end tell
	tell application "Finder" to set desktop picture to anImageFile
	delay 1
end repeat

tell application "Finder"
	set desktop picture to desktop_picture_old
	move picturesFolder to trash
	empty trash
end tell