I would like to create a keyboard shortcut to Clean Up Folder by Name. Which can be done by right-click > Clean up by > Name
What is the Automator code needed to achieve this ?
On my Mac (running 10.7 Lion), there's already a default shortcut for this, ⌥⌘1 (optioncommand1). You can access the Clean Up By menu under the Finder's View menu, which will show the shortcuts assigned:
Note that this option is only available on the Desktop or a Finder window in Icons mode (not List, Column or Cover Flow modes).
If you don't have shortcuts assigned by default, you can add them in the Application Shortcuts section of Keyboard Preferences.