Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > applescript: working with files

applescript: working with files
Thread Tools
Junior Member
Join Date: May 2002
Status: Offline
Reply With Quote
Oct 27, 2003, 07:15 AM
 
I dont understant how files are referenced in applescript. I would like to have a droplet that converts an image to jpeg.

Here is the script I am using. When I run it, I get an error saying the variable this_image is not defined.

What have I done wrong?

on open someFiles
repeat with i in someFiles
try
tell application "Image Events"
set this_image to open file (i as string)
save this_image as JPEG in file newname
close this_image
end tell
on error error_message
tell application "Finder"
activate
display dialog error_message buttons {"Cancel"} default button 1 giving up after 120
end tell
end try
end repeat
end open
     
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status: Offline
Reply With Quote
Oct 27, 2003, 01:33 PM
 
Last time I checked out Image Events I didn't have much luck, so I'm not sure.

But this line looks like there may be something wrong with it:
set this_image to open file (i as string)
i should already be of type alias, since the open handler is passes a list of alias. So just "open i" should work...

BTW, Apple has some examples for scripting Image Events up on their website now. There's also some examples preinstalled for use with Folder Actions.
Rick Roe
icons.cx | weblog
     
patzoul  (op)
Junior Member
Join Date: May 2002
Status: Offline
Reply With Quote
Oct 27, 2003, 09:01 PM
 
can you explain what happens when a file is passed as an alias?
     
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Oct 28, 2003, 05:17 AM
 
Originally posted by patzoul:
can you explain what happens when a file is passed as an alias?
See page 193 of The ASLG
     
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status: Offline
Reply With Quote
Jul 2, 2005, 09:13 PM
 
Have any of you noticed how Image Events has a bug that produces an annoying 1-pixel thick black line usually on the top of an image it has resized? It's driving me insane!
     
   
Thread Tools
Forum Links
Forum 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 On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:19 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2