You can basically do anything with the Open with… menu as long as you know how to use AppleScript and Automator.
Open up Automator.app from Applications, and create a new Application. From the left, drag Run AppleScript to the right pane, and here, paste the following:
on run {input}
set filepath to quoted form of POSIX path of input
tell application "iTerm"
make new terminal
tell the current terminal
activate current session
launch session "Default Session"
tell the last session
write text "python wp.py " & filepath
end tell
end tell
end tell
return input
end run
Like this:
As you can see, the code will first create the POSIX-compatible path from the input file you opened the app with. It needs to be quoted in case the path contains spaces. Then, we'll tell iTerm to open, create a new tab, then write the command as text to the console.
Save this as an application, and use this to open your file with. To do that, right-click on the file you want to use your new app with, click Get Info, and under Open With » Other…, select your new app – note that I chose an HTML file here, but it doesn't matter which type. Make sure to tick Always Open With if you want it to be applied for all files of that type.
Now, double-click the file, and there you go:
Ehhxcellent. Thank you very much. I must learn AppleScript. – Tony – 2012-08-05T01:14:13.083