Need Action to select or invoke "Show Contents" . .

I have worked on this off and on for a couple of weeks including many searches here and on Google with no joy. I need an Action that will in essence select and execute, right click then go to the option “Show Contents”, or invoke the command directly (best) on an already selected app. From there all actions needed I know what to do. Kinda. Also I can not find any actions that will select a specified file or folder, unless that is the “Reveal” action? Which I already have in place and is working perfectly up until now and how it will work after the “Show Contents” action.

I already have the macro to the point of “revealing” the app that I need to “Show Contents” on. And what I need to do from “Show Contents” and go from there . . .

I am working in 10.11.6 with KBM 7.3.1.

Any assistance will be greatly appreciated.

Thank you.

Here is an AppleScript I found myself at the MacScripter Forum that shows the contents of the currently selected (application) bundle:

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

Another AppleScript approach, which just needs to be invoked when the Finder application is selected. I’m not certain where I found this script years ago, but it’s always worked reliably.

tell application "Finder"
	set selectedItems to selection
	set selectedItem to item 1 of selectedItems as alias
	delay 0.25
	open folder ((selectedItem as string) & "Contents:Resources:")
on error
	display dialog "This isn't a package."
end try
end tell

Thank you both for your replies. Looking at your scripts you gave me the foundation to think it through and figure it out.

tell application "Finder"
   set target of Finder window 1 to application file "" of folder "Level 4 folder" of folder "Level 3 folder" of folder "Application Support" of folder "Library" of startup disk
end tell

It pops that app or any targeted app right open. Now all I have to do is add in the tail end and it’s complete.

Thank you!!

To those that so graciously tried to help me, I stumbled, once again, this time on the definitively best and simplistic way to do what I was looking to do.

Using the Reveal File action:
Reveal File ‘/Library/Application Support/folder/folder/ Name’ < to be acted on.

Going this route you tunnel through the .app file that I was looking to properly open/see contents then travel into then act on an interior file. Not having to reveal the contents of the .app and tunnel to the right file, made all the difference. AND if the file is not there the macro does nothing and you just sit there. Next will to be work in a signal that tells me there’s nothing to do.

It’s always the simple things that elude you. I was just over thinking it. Thanks.

Hey @FarmerBob

You can have Keyboard Maestro tell you if a file is present at a specific path:



1 Like

@ccstone Great minds think alike . . . .

30 PM

Going in:

When finished, if action was taken . . .

Next is to try and see if the Delete action will serve double duty as reveal and delete all at once without individual revealing and delete key steps. I have it set to run the next time the file shows up. So it'll be interesting to see what happens . . .

Well it's been a while and I was able to get this not only working great a long while ago. And ironically the "Show Contents" part was the easy part after all. It fires off at all kinds of triggers, Notifies me, Dings me and in the Australian Male voice that is the personae on my machine tells me want happened. Now that I have been using for a while a problem have developed. In order to the delete the file it has to be "Revealed" in the Finder, then deleted using the "Delete" key, then I have it set to auto fill the authorization window, send it off and clean up. I would like it if it could do all that behind the scenes. Since having it running for some time I have found that if I am working while it fires off, I get in the way. I have tried several things and each fails and what with the way "Notifications" work, I can't get the whole error so I can debug.

I have been reading in here all night and then did a search on the net that brought me back here. I found a topic that is really close to what I want to do. How to make a macro that deletes or trashes a file from the /libary folder? But it kinda get left hanging. Just like the OP is the post, I would like to locate and delete the file in the /Library directory without having to reveal it and go through all the hoopla. I can easily locate the file and reveal it in the Finder. In the post Peter chimed in and said:

"You wont be prompted for your admin password, no. The action should fail and report the failure, depending on the action settings.

"If it needs the admin password, then you’ll have to find an alternative, such as executing an AppleScript and executing the rm command with administrative permissions, so setting up an entry in the sudoers file to allow it to be executed without a password and running a sudo rm command."

I understand what he's saying and am having flash backs. So I went hunting for the resources to do the AppleScript. I dabbled in AS years ago and it wasn't all that bad. But now I'm the one that's bad. It just won't click for me. A lot of things aren't clicking for me lately.

So I'm wondering if anyone has a script/macro action or could direct me to one or the resources or help me in any other way, I would be most appreciative.

Hey Bob,

It's not entirely clear what you're doing, but here's an example.

If you're more specific about what file you need to delete I can help you further.


set appFile to alias ((path to downloads folder as text) & "")

tell application "Finder"
   set fileToDelete to file "embedded.provisionprofile" of folder "Contents" of appFile
   delete fileToDelete
end tell

Thanks! That's simple and sweet. Do I need the first line? It's been a while and like I said these things aren't clicking for me right now.

I have a file that gets generated in an app that's part of the /Library items of an app. It is resetting pallet placement in the app when the app is restarted with the file there. If the file is deleted before the app is started, the pallets stay where they was last left.

I have altered a test KM with your code and will try it and let you know. This is great! Thank you!!

Hey Bob,

Yes in the case of my script.

But you can provide a full address to the file as alias or Finder specification instead.

You can also use a POSIX Path and POSIX file like so:

tell application "Finder"
   set myFile to POSIX file "/Users/myUserName/test_directory/Quotes.txt"
end tell