The easiest, built-in way to do this is to just drag the items from Finder to a Terminal window. When you drop them, Terminal will “type” their (escaped) pathnames. You can then use your shell's command line editing to enter the rest of the command. Or if you are thinking ahead, you can type the command first then drag in the items.
The “drag first” version:
- Select and drag some Finder items to a Terminal window that is showing a shell prompt. Terminal will insert the (escaped) pathnames.
- Type Control+A (go to the beginning of the line; ⌃A is the default, but varies by shell/configuration).
- Type your command and a space (it will be inserted before the pathnames).
The “thinking ahead” version:
- In any order, do both:
- In a Terminal window, type the initial part of your command and space (everything except the pathnames).
- Select some items in Finder.
- Drag the selected items from Finder to the Terminal window where you typed the command.
- Activate the Terminal window and press Return.
You can (as other answers have indicated) turn to AppleScript or Automator if you need more a more automated solution. Since the extra “moving parts” can add some complexity to the solution, you will have to weigh the benefits of the above process (manual, but flexible) against the the complexity of implementing one or more of the automated solutions.
Some of the automation possibilities include:
- an AppleScript droplet application
- a plain AppleScript program launched by the built-in script menu or other launcher
- get pathnames from Finder's selection
- an Automator workflow, application, or Finder plug-in
- an executable
.command file (usually a shell script; open in Finder to run it in Terminal)
- get pathnames from Finder's selection (via osascript)
- some third-party tool that already provides the functionality you need