On Oct 20, 2015, at 20:21, Michelle <[email protected]> wrote: > Can anyone help me with this? I have the following, very helpful AppleScript > that capitalizes the first letter of every word that I select/highlight: ______________________________________________________________________
Hey Michelle, This sort of job is precisely why I've used the Satimage.osax <http://www.satimage.fr/software/en/downloads/downloads_companion_osaxen.html> since 2003. The fixedCaseWordList lets you designate the case of any given word. It is arranged vertically for easy maintenance and sorting. First and last words in the title are adjusted at the end of the script. On my system the handlers are hidden in a library. Back in the days I could use Eudora I had a 1000+ line script that reformatted reply-text using various rules for different email lists and people. It hijacked Reply's keyboard shortcut and was only about 0.2 seconds slower than a normal reply. I had a similar script for editing the junk out of list-mail I wanted to keep. -- Best Regards, Chris ------------------------------------------------------------------------------------------- # Auth: Christopher Stone <[email protected]> # dCre: 2015/10/21 17:20 # dMod: 2015/10/21 17:52 # Appl: BBEdit & the Satimage.osax # Task: Change case of selected text to title-case. # Libs: None # Osax: Satimage.osax { http://tinyurl.com/dc3soh } # Tags: @Applescript, @Script, @BBEdit, @Change, @Case, @Selected, @Text ------------------------------------------------------------------------------------------- # SCRIPT REQUIRES INSTALLATION OF THE SATIMAGE.OSAX APPLESCRIPT EXTENSION! ------------------------------------------------------------------------------------------- set fixedCaseWordList to paragraphs 2 thru -2 of " a AFL-CIO an and as at but by for from in into it NAACP nor of on onto or so the to with " set lowerCaseWordRegEx to change "(.+)" into "\\\\b\\1\\\\b" in fixedCaseWordList with regexp without case sensitive set _text to getSelectionOfNamedBBEditWindow(1) set _text to titlecase _text set newText to change lowerCaseWordRegEx into fixedCaseWordList in _text with regexp without case sensitive set newText to change "^(\\w)" into "\\u\\1" in newText with regexp without case sensitive set newText to change "(\\w)(\\w*)$" into "\\u\\1\\2" in newText with regexp without case sensitive setBBEditTextSelectionTo(newText) ------------------------------------------------------------------------------------------- --ยป HANDLERS ------------------------------------------------------------------------------------------- on getSelectionOfNamedBBEditWindow(_window) tell application "BBEdit" if _window = "front" then set _window to window (name of front text window) else if class of _window = integer or class of _window = text then set _window to text window _window end if tell _window to return contents of selection end tell end getSelectionOfNamedBBEditWindow ------------------------------------------------------------------------------------------- on setBBEditTextSelectionTo(_text) tell application "BBEdit" to set contents of selection's text to _text end setBBEditTextSelectionTo ------------------------------------------------------------------------------------------- -- This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email "[email protected]" rather than posting to the group. Follow @bbedit on Twitter: <http://www.twitter.com/bbedit> --- You received this message because you are subscribed to the Google Groups "BBEdit Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
