Use OS X Commands in AppleScript Today

It's month end and you need to fill in your time sheets but the time reporting system speaks in week numbers. Well fear not ... using your developer super powers you can use the humble date command and Apple Script to put a GUI on it (tm). In fact there are a whole host of OS X commands you can use to increase your developer super powers. Can you feel the energy...

Back to the OS X Command Line. To get the Week number use the date command:

date +%W

The +%W argument indicates format the current date as a Week Number.

Add the GUI using Apple Script you execute the date using the shell as follows:


set output to do shell script "date +%W"


Next Display a dialogue box with the output obtained from the
Darwin bash shell easy use following:


display dialog prompt with title "Week Number" buttons {"OK"} default button 1

Where the prompt is a concatenation of the description and shell output text.


set prompt to "Current Week Number : " & output as text





Now as you can see the OS X utilities are endless...

0 comments: