print random image

is there a way to use apple script to take a random jpeg file from a filder full of jpegs and instantly print one at random?

thanks

perhaps if all the images within the folder were open in preview, apple script could use keystrokes to print my image

keystroke “p” using command down
delay 1 – (seconds)
keystroke return
delay 2 – (seconds)
keystroke return

but before this it could keystroke (down arrow) so every time apple script returns to preview, it selects the next image, this would be the easiest way to do what i want to do i think. seems like pretty simple script too, could anyone give me a hand writing it? thankyou

Hello.

This one lets you show previews of the images you have selected in a folder. Select the files in a folder, run the script, and preview them.

-- Works on a selection of a finder window, if first item is a folder, the contents of that folder is selected
-- © McUsr and put in public domain, you may not post this elsewhere, or put it in a public accessible repository
-- but refer to this post! http://macscripter.net/post.php?tid=39516
script GanderFolder
	on run
		local fl, alilist
		set fl to {}
		tell application "Finder"
			set alilist to selection as alias list
			if alilist = {} then error number -128
			if (count alilist) = 1 and class of item (item 1 of alilist) is folder then
				set alilist to every file of item 1 of alilist as alias list
			end if
			repeat with analias in alilist
				if class of item analias is folder then
				else if displayed name of item analias is ".DS_Store" then
				else
					set end of fl to analias
				end if
			end repeat
		end tell
		gander(fl)
	end run
	
	on gander(_files)
		try
			repeat with _file in _files
				do shell script "{ sleep 2 ; killall qlmanage ; } & qlmanage -p " & quoted form of POSIX path of _file
			end repeat
		on error e number n
			if n ≠ -128 then display dialog e & " : " & n
		end try
	end gander
end script
tell GanderFolder to run