Each of the languages has strengths and weaknesses. By bringing them all together on a single platform, and making it easy for them to be used together, Apple has put an amazing amount of automation power in our hands.
As shown in previous posts AppleScrunix allows me to work primarily in AppleScript and draw from other languages when my scripting language of choice comes up a bit short.
I often run across the need to do ‘simple’ title case conversion. ‘Simple’ meaning every word in the title has its first letter capitalized and all remaining letters are lowercase. Though this is possible using only standard AppleScript, the project quickly becomes complicated and ends up running slower than it needs to.
If you are interested in solving this problem just using AppleScript, you can get much of the code you need from my previous post, Applescript – Converting Uppercase & Lowercase (AppleScrunix Style).
Or you can do it using AppleScrunix and just 2 lines of code. I have messed up the title ahead of time to make it more interesting… thIs is thE stORY of a GIRL becomes This Is The Story Of A Girl.
set myTitle to "thIs is thE stORY of a GIRL"
do shell script "python -c \"print " & quoted form of (myTitle) & ".title()\""
Result: “This Is The Story Of A Girl”
AppleScript / AppleScrunix Examples – using the do shell script command in AppleScript.
2011-06-30 » Russ Leseberg