Re: Drag and drop onto BSD command line tool?
Re: Drag and drop onto BSD command line tool?
- Subject: Re: Drag and drop onto BSD command line tool?
- From: Bob Sabiston <email@hidden>
- Date: Sat, 17 May 2014 19:02:35 -0500
> On May 17, 2014, at 6:26 PM, Kevin Meaney <email@hidden> wrote:
>
>> I think an applescript droplet, using the "on open" call which then calls "do shell script" with the path to your command and the file that is dropped on it.
>>
>> Kevin
>
>
>>> You have to create the right kind of Automator workflow for dropping files onto, then you have to select from a popup what to do with the input, then you write your script.
>>
>> Duh. Step 1.5, you add a "Run Shell Script" action to your workflow.
>>
>
> OK thanks — I am trying this and it almost works. It does run the script, but it is not passing the dropped filename as an argc/argv argument. The script just reports that it gets no arguments. I did set “Pass Input” on the “Run Shell Script” to “as arguments”, so it seems like it should work.
>
> Within Automator, you have to add a “Get Specified Finder Items” action before the script, if you want to run it within Automator. I tried that, and it just doesn’t seem to pass the filename as an argument. Maybe it is actually passing the *contents* of the dropped file, instead of just its filename? But my script is reporting no arguments besides the script name.
OK I found out why here:
https://discussions.apple.com/message/10847479#10847479
It doesn’t just pass the name, it passes a list of arguments. So I had to put this in the Run Shell Script window:
for f in "$@"
do
myScript "$f"
done
Thanks for the help!
Bob
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden