Applescript Random Image + Open

blandinnovation

Registered
Hello,

I was wondering if there was any way to combine two applescripts. I am not familiar to applescript, and in fact only need it for a photo project. So far I have the Applescript to get a random image:

tell application "Finder"
(* get a random image file from a desktop folder *)
set randomImage to some file of folder "Photo Final"

end tell



and I have the Applescript to open the picture I want:

tell application "Preview"
launch
open "Macintosh HD:continuefilepath.jpg"
end tell



Can someone help me combine the codes so that Preview opens whatever random image the first code generates?
 
Try it like this:
Code:
tell application "Finder"
	set randomImage to some file of folder "Photo Final"
end tell

tell application "Preview"
	open randomImage
end tell

I actually never knew you could say "some file of folder...." to get a random choice before. Neat!
 
Hey thanks,

Through some trial and error I was able to figure it out. I need three images to appear at once for my presentation.

Here's the code I used.

tell application "Finder"
(* get a random image file from a desktop folder *)
set randomImage to some file of folder "Photo Final"
open randomImage
set randomImage to some file of folder "Photo Final 2"
open randomImage
set randomImage to some file of folder "Photo Final 3"
open randomImage
end tell

Thanks for the help anyways! The images open under Preview as default, so I didn't have to go through the whole "tell application 'Preview' " It would come in handy if I were handling RAW images that would default to photoshop however.
 
Back
Top