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

sorryiwasdreami

macrumors 6502a
Original poster
Apr 24, 2004
699
1
way out in the sticks
I've been searching all over the place to find a way to add a contextual menu item to finder. It looks like they can be added using Applescript or via a finder plugin.

Anyway, I can't find the one I'm looking for anywhere. It already exists in os x and is under the "view" menu. It's the "Clean Up" function; it's the action that cleans up icons and aligns them to a grid. What I need is that exact same action under the menu when I right click in a finder window—just a simple "Clean Up" under the contextual menu upon right clicking.

I really don't want an application to handle this or any complicated solution. The key is to simply right click and select it. It would work in any finder window's contextual menu. Having this would really speed up my workflow.

Does anyone know where to get such a plugin/Applescript? Does anyone know how write one (or know how to copy the existing one)? That would be exquisite.
 

XNine

macrumors 68040
Well, you build your actions in Automator, and then when you're done you SAVE AS... Finder Plugin and it puts it under the contextual menu. I'm pretty sure thsi can be done in automator, but I'm at work right now and don't have access to automator here.

IF need be I'll build the script and host it for you to DL.
 

sorryiwasdreami

macrumors 6502a
Original poster
Apr 24, 2004
699
1
way out in the sticks
I have used Automator to build several workflows such as setting my display to sleep or remain awake, rename, and combine pdfs. But, I used actions that were already present in automator to do this and then save as plugins.

So I understand how to save automator actions as finder plugins, but I don't know how to import an action in order to make it available for use.

Any help would be very much appreciated; I'm interested in learning how to do this.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
See attached (created in Automator). You need to unzip this and save it in ~/Library/Workflows/Applications/Finder/

So how did I do it?

To start with I looked at the available Automator actions and realised none of them would help.

So I fired up the script editor and opened the Finder dictionary and quickly find the Clean Up command.

So I wrote this script:

Code:
tell application "Finder"
	tell front window to clean up
end tell

which seemed to work (it tells whatever the front-most Finder window is to clean up.

So I then looked into Automator and found the AppleScript action in the Automator section. A quick copy and paste of that code and I was done.

Enjoy :D
 

Attachments

  • Clean Up.workflow.zip
    1.7 KB · Views: 92

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
OK I've found an annoyance: the Finder window you right click in looses focus :(

To fix this change the code in the action to

Code:
on run {input, parameters}
	
	tell application "Finder"
		tell front window to clean up
		activate
	end tell
	
	return input
end run

(Note the activate line)
 

sorryiwasdreami

macrumors 6502a
Original poster
Apr 24, 2004
699
1
way out in the sticks
Wow awesome! I didn't know there were these "dictionaries." Thanks for all your help!

I am getting errors with the script, but I am looking into it and trying to figure out why.

Thanks again.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
sorryiwasdreami said:
Where in the Finder dictionary can you see the actual scripting code for these things? How do you show it?

What do you mean by "actual scripting code"? The dictionary tells you about the objects that are available and the properties and methods those objects expose. That's all you need.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.