I have a shell script that takes two arguments:
- full file path
- file name
How can I use Automator to add a context menu entry to Finder to run the shell script with a chosen file path and file name as arguments?
Select to create a Service in Automator that receives selected files and folders as input in Finder only. Add the Run Shell Script action and pass input as arguments.
The arguments you receive are the full Unix paths of the selected files and folders. Using
Growl message as a result of running it on a file:
The command appears in the context menu of a file or folder in Finder. If there are too many applicable Services, they are grouped into a submenu Services.
If your script requires both the full file path, and the file name, you can do something like the following, first extracting the file name from the full path:
You can see that the file name is used as title, while the path is used as message in Growl:
If you need to query for additional input, you can execute a short AppleScript to do that. The following is a complete shell script (like the
Screenshot of a sample rename action announced via