Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

surfcity

macrumors newbie
Original poster
Apr 27, 2010
2
0
Hi Guys!

I tried to write a Script to call with a System Service via a Shortcut to open a specific file, based on its filename extension. But the Applescript i wrote ends with an error message that the "name extension of" cannot be read.

Does anyone of you guys have an idea what i am doing wrong?

Thank you very much.

Here's my script:

Code:
global appName
property image_extension_list : {"tif", "tiff", "gif", "png", "pict", "pct", "jpg", "jpeg"}
property text_extension_list : {"html", "txt", "css", "php", "js"}

on run {input, parameters}
	
	tell application "Finder"
		if (the name extension of the input is in the image_extension_list) then
			set appName to "Adobe Photoshop CS3"
		end if
		
		if (the name extension of the input is in the text_extension_list) then
			set appName to "TextMate"
		end if
	end tell
	
	tell application appName
		activate
		open input
	end tell
	
	return input
end run

This is intended to be a "Edit File" Script. For example: GIF-Files are normally linked with Preview-App. This is fine - but i want to call my Script to open it in Photoshop to edit it. :)
 
I think you're missing an (info for input) or an (input as alias). If 'input' isn't a file alias, it won't have a name extension property.
 
I think you're missing an (info for input) or an (input as alias). If 'input' isn't a file alias, it won't have a name extension property.

Thank you OP for this script.
Call me stupid, but I don't understand how to implement that 'info for input' or 'input as alias', could you please explain or better yet show an example? :confused:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.