• 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: Manipulating text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Manipulating text


  • Subject: Re: Manipulating text
  • From: Luther Fuller <email@hidden>
  • Date: Fri, 25 Sep 2009 08:35:04 -0500

On Sep 25, 2009, at 8:07 AM, Jim Brandt wrote:
I have a script that I use to manipulate the names of the files
within a folder. I want the names to be word capitalized, all underscores
changed to spaces, and optionally, based on an input response,
the first word of the name uppercased.

Anything you can do with plain text in a text editor, you can do much faster in AppleScript.
For example ...

(*
id of "a" -- 97
id of "z" -- 122
id of "A" -- 65
id of "Z" -- 90
*)

set firstWord to "xnchdgrtsjdlvmfqq12345"
set charList to characters of firstWord
repeat with i from 1 to (count items of charList)
set charID to id of (item i of charList)
if (96 < charID) and (charID < 123) then
set charID to (charID - 32)
set item i of charList to (character id charID)
end if
end repeat
set firstWord to charList as text

converts text to upper case.

Use 'AppleScript's text item delimiters' whenever possible.
For example, something like this ...

set AppleScript's text item delimiters to {"_"}
-- get a list of text chunks separated by "_"
set AppleScript's text item delimiters to {space}
-- convert the list of chunks to text separated by " "

will convert underscores to spaces.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Manipulating text
      • From: "Mark J. Reed" <email@hidden>
References: 
 >Manipulating text (From: Jim Brandt <email@hidden>)

  • Prev by Date: Manipulating text
  • Next by Date: Re: Manipulating text
  • Previous by thread: Manipulating text
  • Next by thread: Re: Manipulating text
  • Index(es):
    • Date
    • Thread