Create a drag and drop interface to shell scripts
Nov 25, '02 09:01:27AM • Contributed by: ClarkGoble
Nov 25, '02 09:01:27AM • Contributed by: ClarkGoble
I didn't come up with this hint, but have used it enough so as to submit it. A lot of people have created application "wrappers" for shell scripts using either dropscript or iHook. However they don't always do the job like you may wish. An alternative is to use Applescript.
For instance if you wish to run a Unix command on each file you drop on the Applescript you can do the following:
This is very nice for running some shell command on the file for filtering it before opening it with another file. For instance, you can use the following script to open PostScript files in Acrobat. It works by using ps2pdf (available as part of Fink) to first convert the file to a temporary PDF file. You can obviously make this a little more robust if you open multiple PostScript files at the same time.
[Editor's note: I have not tested this hint myself.]
For instance if you wish to run a Unix command on each file you drop on the Applescript you can do the following:
on open filelistA nice feature of OSX is that you can associate any application with a kind of file. First save your script using Script Editor as an application. Then select a file of the type you wish to associate with your script. Select "Get Info." Select the "Open with" pane and then select your Applescript application. Click the "Change All" button. Now every file of that extension will open up with your Applescript.
repeat with i in filelist
do shell script "my_command " & POSIX path of i
end repeat
end open
This is very nice for running some shell command on the file for filtering it before opening it with another file. For instance, you can use the following script to open PostScript files in Acrobat. It works by using ps2pdf (available as part of Fink) to first convert the file to a temporary PDF file. You can obviously make this a little more robust if you open multiple PostScript files at the same time.
on open input_fileThe "do shell script" command is shown on two lines; enter it as one line with a space after the "&".
do shell script "export PATH=\"$PATH\":/sw/bin;ps2pdf \"" &
POSIX path of input_file & "\" ~/.psview.tmp.pdf; open ~/.psview.tmp.pdf"
end open
[Editor's note: I have not tested this hint myself.]
•
[13,434 views]
