Applescript to open "Show Package Contents"

Can one write an apple script to control-click a already “selected” file in Finder and then click on
“Show Package Contents”? Because I dont know of any keyboard shortcut which would “Show Package Contents” of a file
Thanks

Hi

try this


tell application "Finder" to set sel to selection
repeat with oneItem in sel
	if package folder of (info for oneItem as alias) then
		try
			tell application "Finder" to open folder ((oneItem as text) & ":Contents")
		end try
	end if
end repeat

save the script as application bundle and drag it into a Finder window next to the search field

Thanks StefanK. It works and I saved it as a script and assigned it a keyboard shortcut with Quicksilver. I dont understand why you asked me save it as an application bundle unless you thought I wanted to click on the icon with a mouse after selecting the file.

Ditto. Works well as a triggered script; single key combo gets me contents window of selected app. Thanks Stefan.

Is there a way to script the Finder to show the top-level of the package? It makes sense for a script dealing with .app packages to go directly to the Contents folder of the package, but I’ve been looking for a way to script showing package contents for .rtfd and .pages packages, where the good stuff is often at the top level. Any ideas?

Strange!!! It seems like there was no need for an applescript. Seems like, shortcuts can be set for all contextual menu items just like menu bar items.
I set the “Show Package Contents” shortcut in keyboard preferences after seeing this article.

http://www.macworld.com/article/131074/2007/12/105kbdtricks.html