image
image

Go Back   macosx.com > Mac Help Forums > Mac OS X System & Mac Software

Reply
 
LinkBack Thread Tools
  #1  
Old April 23rd, 2009, 11:30 PM
Registered User
 
Join Date: Apr 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
blandinnovation is on a distinguished road
Applescript Random Image + Open

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?
Reply With Quote
  #2  
Old April 24th, 2009, 12:11 AM
Mikuro's Avatar
Crotchety UI Nitpicker
 
Join Date: Mar 2005
Posts: 2,682
Thanks: 6
Thanked 53 Times in 48 Posts
Mikuro will become famous soon enough
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!
__________________
Mac mini — 1.25GHz G4, 1GB RAM — OS 10.5.8

Useful programs: Privoxy, Butler, ffmpegX, VLC, Perian, Tofu, Wcalc
Reply With Quote
  #3  
Old April 24th, 2009, 03:42 AM
Registered User
 
Join Date: Apr 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
blandinnovation is on a distinguished road
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.
Reply With Quote
Reply

Bookmarks

Tags
applescript

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump


All times are GMT -5. The time now is 02:46 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC1
Copyright 2000-2010 DigitalCrowd, Inc.