• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Name rearrangement
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Name rearrangement


  • Subject: Re: Name rearrangement
  • From: Christopher Stone <email@hidden>
  • Date: Tue, 30 Mar 2004 04:25:24 -0600

On Mar 30, 2004, at 2:04 AM, Jim Witte wrote:
What's a script that will take a name in the form of "STOOGE, CURLY" and turn it into "Curly Stooge" This would be an absolute cinch in PHP or Perl - but I'd rather not have to be calling out to the Terminal to execute a Perl one-liner every time I want to do this..

----------------------------------------------------------------------

-- Vanilla AppleScript

set theName to "STOOGE, CURLY"
set AppleScript's text item delimiters to {" "}
set theName2 to reverse of ({word 1, word 2} of theName) as string
set AppleScript's text item delimiters to {""}
theName2

-- Using the Satimage osax

set useRegEx to change "(\\w+), (\\w+)" into "\\2 \\1" in theName with regexp without case sensitive

-- Use Satimage osax to form title case

set useRegEx to words of (lowercase useRegEx)
repeat with i in useRegEx
set contents of i to (uppercase (character 1 of i)) & (text 2 thru -1 of i)
end repeat
set AppleScript's text item delimiters to {" "}
set useRegEx to useRegEx as string
set AppleScript's text item delimiters to {""}
useRegEx

----------------------------------------------------------------------

I've wished for some time that the Satimage osax would do title-case and sentence-case, but alas...

The Satimage osax:

http://www.satimage.fr/software/en/downloads_osaxen.html

The old RegEx Commands osax for Mac OS 9 would do case conversion, and some other things I miss on Mac OS X.

Personally I use the ACME Script Widgets osax to do case conversions, but it's commercial ($29.00).

<http://www.acmetech.com/index.php?module=pagemaster&PAGE_user_op=view_page&PAGE_id=7&MMN_position=21:12>


Chris
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


References: 
 >Name rearrangement (From: Jim Witte <email@hidden>)
 >Re: Name rearrangement (From: Joseph Weaks <email@hidden>)

  • Prev by Date: Re: Name rearrangement
  • Next by Date: Re: OS X File system Layout (was Re: AppleScript & HTML Again...)
  • Previous by thread: Re: Name rearrangement
  • Next by thread: Re: Name rearrangement
  • Index(es):
    • Date
    • Thread