Applescript glue; dropplet magic

Posted by sh1mmer on Dec 21, 2006 in Mac |

Norm wrote a super perl script to ensure that when you open iCal files sent to a mailing lists it uses the correct to address. This avoids having to have all the mailing list addresses in your own card in your address book. However he did note that OS X doesn't allow you to set a perl script as a file action. So it is impossible to open ics files with the perl by default.

After some googling I came up with this Applescript. It's a small 'droplet' which takes a file input and then calls the perl function after translating the path into POSIX for it. This script is great to act as glue between the GUI and CLI applications.

APPLESCRIPT:
  1. on open icsFileRef
  2.     set icsPath to quoted form of POSIX path of icsFileRef
  3.     do shell script "perl /Applications/AppleScript/Scripts/fixics.pl " & icsPath
  4. end open

Apple have a more complete description of how to write out dropplets to handle things like multiple file types and folders and nested folders etc. I like the idea that you could make a launcher droplet in applescript which would then exectute whatever else you wanted for each file type, context, etc.

Technorati Tags:
, ,

Share with friends:
  • Twitter
  • HackerNews
  • del.icio.us
  • Reddit
  • Digg
  • StumbleUpon

blog comments powered by Disqus

Copyright © 2010 Kid666 Blog All rights reserved. Base theme by Laptop Geek.