Hi Allen!

Thanks a lot! It works!

ATB - 2007-02-01, 21?h?24 EST

-- 



> From: Allen Watson <[EMAIL PROTECTED]>
> Reply-To: "Entourage:mac Talk" <[email protected]>
> Date: Thu, 01 Feb 2007 08:26:11 -0800
> To: "Entourage:mac Talk" <[email protected]>
> Subject: Re: Script to modify phone number format
> 
> First, have you selected your desired format in Entourage's
> preferences, under Address Book? That way any new numbers you enter
> with just the digits will automatically get your desired format.
> 
> Second, to revise the format of existing numbers you need a modified
> script. The following will reformat all the phone numbers of all
> selected contacts. I advise doing a small number at a time until you
> get a feel for how long the script will run. Test it out on 1 or 2 to
> see if the result is what you want. Copy and paste into Script Editor,
> save with a name of your choice in Entourage Script Menu Items folder:
> 
> -- DaveCort 4/12/04: added repeat loop to process every phone number
> associated with the selected contact
> -- DaveCort 4/12/04: added empty string check in reformat to improve perf
> 
> property phoneTypes : {"Home phone number", "Business phone number",
> "Mobile phone number", "Home fax phone number", ¬
> "Business fax phone number", "Pager phone number", "Assistant phone
> number", "Other home phone number", "Other business phone number", ¬
> "Custom phone number one", "Custom phone number two", "Custom phone
> number three", "Custom phone number four"}
> 
> 
> tell application "Microsoft Entourage"
> activate
> try
> set theList to the selection
> on error theErr number errNum
> if errNum = -1728 then
> -- Try formatting the text on the clipboard
> set t to the clipboard
> set t to my reformat(t)
> set the clipboard to t
> try
> set the selection to t
> on error
> display dialog "Clipboard now contains: " & t
> end try
> return
> else
> display dialog "Error number:" & errNum & " " & theErr
> return
> end if
> end try
> repeat with theC in theList
> if class of theC is not contact then
> if class of theC is string then
> -- Try formatting the text on the clipboard
> set t to the clipboard
> set t to my reformat(t)
> set the clipboard to t
> try
> set the selection to t
> on error
> display dialog "Clipboard now contains: " & t
> end try
> return
> end if
> display dialog "No contacts are selected."
> return
> end if
> set theID to (the ID of theC as string)
> repeat with i in phoneTypes
> set pn to run script "tell application \"Microsoft Entourage\" to
> return " & i & " of contact ID " & theID
> set newpn to (my reformat(pn)) as string
> if newpn ≠ pn then run script "tell application \"Microsoft
> Entourage\" to set " & i & " of contact ID " & theID & " to \"" &
> newpn & "\""
> end repeat
> end repeat
> end tell
> 
> 
> on reformat(pNum)
> if pNum = "" then return ""
> set pNum to my onlyDigits(pNum)
> set pNum to my formatNum(pNum)
> return pNum
> end reformat
> 
> 
> on onlyDigits(s)
> -- Strip all but digits from a string
> set theDigits to "1234567890"
> set newS to ""
> repeat with i from 1 to length of s
> set c to character i of s
> if c is in theDigits then set newS to newS & c
> end repeat
> return newS
> end onlyDigits
> 
> 
> on formatNum(n)
> -- Insert USA telephone formatting
> --Choose one of two formats, comment out one unused
> set mask to "+1-AAA-PPP-NNNN"
> -- set mask to "AAA-PPP-NNNN"
> if length of n is 10 then
> set aaa to text 1 thru 3 of n
> set ppp to text 4 thru 6 of n
> set nnnn to text 7 thru 10 of n
> set mask to my searchReplace(mask, "AAA", aaa)
> set mask to my searchReplace(mask, "PPP", ppp)
> set mask to my searchReplace(mask, "NNNN", nnnn)
> set n to mask
> else if length of n is 7 then
> set n to text 1 thru 3 of n & "-" & text 4 thru 7 of n
> end if
> return n
> end formatNum
> 
> 
> -- routine to do a search and replace on text
> on searchReplace(mainString, searchString, replaceString) --
> Parameters: search, replace, the String
> set olddelis to AppleScript's text item delimiters
> 
> set AppleScript's text item delimiters to (searchString)
> set theList to (every text item of mainString)
> 
> set AppleScript's text item delimiters to (replaceString)
> set theString to theList as string
> 
> set AppleScript's text item delimiters to olddelis
> return theString
> end searchReplace
> 
> On 1/30/07, ATB <[EMAIL PROTECTED]> wrote:
>> Does anyone know of a script that will examine all my contacts, and modify
>> all phone numbers, be they work, mobile, fax, pager to a specific format,
>> where there is a "+" at the beginning of the number, followed by the area
>> code, and then the 7-digit phone number, i.e. +1-AAA-BBB-CCCC? Of course,
>> not touching those with the right format.
>> 
>> Up until now, what I have seen are scripts that change only the home phone
>> number to the format that I want or that change only to the home phone
>> number to the following format 514-555-0000.
>> 
>> For example, here's what I would want
>> 
>> 514-555-0000   -> +1-514-555-0000
>> 5145550000     -> +1-514-555-0000
>> 1-514-555-0000 -> +1-514-555-0000
>> 15145550000    -> +1-514-555-0000
>> 
>> (514) 555-0000   -> +1-514-555-0000
>> (514)5550000     -> +1-514-555-0000
>> 1 (514) 555-0000 -> +1-514-555-0000
>> 1(514)5550000    -> +1-514-555-0000
>> 
>> +1-514-555-0000 -> +1-514-555-0000
>> 
>> Thank you.
>> 
>> Antoine, 2007-01-30, 23h51 EST
>> 
>> 
>> 
>> --
>> To unsubscribe:
>> <mailto:[EMAIL PROTECTED]>
>> archives:
>> <http://www.mail-archive.com/entourage-talk%40lists.letterrip.com/>
>> old-archive:
>> <http://www.mail-archive.com/entourage-talk%40lists.boingo.com/>
>> 
>> 
> -- 
> To unsubscribe:  
> <mailto:[EMAIL PROTECTED]>
> archives:       
> <http://www.mail-archive.com/entourage-talk%40lists.letterrip.com/>
> old-archive:     
> <http://www.mail-archive.com/entourage-talk%40lists.boingo.com/>
> 


-- 
To unsubscribe:                     
<mailto:[EMAIL PROTECTED]>
archives:       
<http://www.mail-archive.com/entourage-talk%40lists.letterrip.com/>
old-archive:       
<http://www.mail-archive.com/entourage-talk%40lists.boingo.com/>

Reply via email to