 |
 |
AppleScript drag-and-drop application that performs terminal command?
|
 |
|
 |
|
Senior User
Join Date: Feb 2004
Location: Lost in a "plus" world
Status:
Offline
|
|
I'd like to see about making an AppleScript that, when files are dragged on to it, performs a terminal command on those files automagically.
Is this possible, and if so, where in the world do I go for information / example code on putting this together?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status:
Offline
|
|
Originally posted by memory-minus:
I'd like to see about making an AppleScript that, when files are dragged on to it, performs a terminal command on those files automagically.
Is this possible, and if so, where in the world do I go for information / example code on putting this together?
Use AppleScript Studio. The shell script itself is easy -- just call "do shell script" from within AppleScript.
|
|
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Oct 2000
Location: Midwest
Status:
Offline
|
|
I agree with Arkham_c that in the end you will use Studio if you use 'do shell script' extensively. To experiment a bit before jumping into Studio, here is an example that may get you started:
--drop small text file on the script icon
-- save as application, we are creating a droplet.
on open _file
set filePosixPath to POSIX path of _file
set theContents to do shell script "cat " & filePosixPath
display dialog theContents
Display dialog has a limitation on characters displayed, so the file needs to be small. You could save the result to a file, you can pipe your stderr to a file- lots of possibilities. Here is the Technical Note on Apple's site that begins to describe 'do shell script'. TN2065
HTH
Craig
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Oct 2002
Location: Left Coast
Status:
Offline
|
|
Originally posted by memory-minus:
I'd like to see about making an AppleScript that, when files are dragged on to it, performs a terminal command on those files automagically.
Is this possible, and if so, where in the world do I go for information / example code on putting this together?
There's a Drag and Drop example in /Developer/Examples/AppleScript Studio folder. You could either modify it (make a private copy first so you still have the original) or you could use it as a guide to create your own app after starting with an AppleScript Studio template project in Xcode.
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Oct 2002
Location: Left Coast
Status:
Offline
|
|
I agree that ASS is overkill if all you want to do is the same operation to all files dropped onto the applet and don't need any significant user interaction. But if you want to do any kind of medium to complex interaction on the dropped items, show status, allow for canceling during lengthy processing or various other GUI type things, then ASS is a good way to do it.
(I saw your smiley Angus_D, but I figured I'd answer the question anyway so that the poster would see why they might want to use ASS.)
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|