Address Book back up & Apple Script
I would like to set my Address Book (and iCal) to back up automatically on my hard drive. I already back it up and sync it to my laptop using .Mac, but I would like to have a back up on my external hard drive, as well.
Can I create an Apple Script to do this or is there a simpler way that I am missing?
I posted a script here a few days ago (see Apple - Support - Discussions - Address book save command ...) - it should be fairly easy to modify it for what you want.
AK
Similar Messages
-
My iPhone is stolen. How can I get my address book back from the iCloud? I should have synchronized my iPad address book. However, I loss some recent contacts from iPhone.
I use my iPad to get the address book backed up by iCloud from my iPhone. However, I cannot see the recent new contacts from my iPad. Is there anyway to check the iCloud server to see if my address book backup from my iPhone is still there?
-
When I try to open my Address Book from Finder, it says :You can't use this version with this version of Mac OS x. I have Address Book 5.0.3 and Mac OS X 10.7.5 What should I do to get my Address Book back???
Unless you deleted Address Book 6, or restored from a backup made before you upgraded to Lion, Address Book 6 should be on your disk somewhere. Try to find it with spotlight or by browsing likely folders with Finder. Also check Trash. If you find other Address Books, using Quick View or Get Info in Finder should show the version number.
Have you ever moved Address Book out of the Applications folder, either before or after you upgraded to Lion?
If you can't figure out how this happened in the first place, I would be worried that other OS X utilities are similarly affected. -
Address Book opens when a script is opened, while script editor was closed
Hi,
Something puzzles me :
I have a very simple script with only these two lines :
tell application "Address Book"
end tell
This script is saved as a simple script.
When I open the script with script editor,
* if script editor was already open, the script opens normally and I can edit it
* if script editor was not already open, then Address Book opens itself (and the script opens itself with script editor)
What explains the opening of Address Book ?
What can I do to avoid this auto-opening of Address Book ?
Thanks for your help,
NicolasYou were right, the script will not compile. (there are some instruction between the "tell" and the "end tell" lines)
There are a couple of solutions to that one.
The first is that the script will compile if you're only using standard commands like 'activate', 'quit', etc. inside the tell block - these commands are universal, supported by all applications, and therefore you don't need the application dictionary.
If you are using application-specific commands, though, then you can provide the Script Editor a hint as to which dictionary to use via the using terms from command.
This tells the compiler which application dictionary to use when compiling the script, but it shouldn't affect opening the script. If you're only targeting one application and don't mind this workaround, it could be your solution:
-- here's our target application
set appName to "Address Book"
-- let's target it
tell application appName
-- now provide the compiler a hint as to which application dictionary to use
using terms from application "Address Book"
-- commands go here
end using terms from
end tell
When it comes to compile the script, AppleScript will use the application in the using terms from statement instead of the (unknown) application in the tell statement. -
Hi
Can anyone give me some useful information on the best ways to design and build a database/booking & dispatch system that can be intergrated through ical, address book and available on my macbook, ipad & iphone and all accessed through icloud.
I started my own chauffuer Service a year ago as an independent. it's becoming a massive bore that most of my time is spent taking down information, checking if i am available for clients and with alot of diary checking and repeatative entries and email ping pong and invoicing, what i want to do is concerntrate on advertising and marketing and using my time off for R & R
What i would like to do is access my information in an app and automate most of the processes like
assigning the job to the client with intergration through iCal and Address Book
be able to email confirmation through mail with an invoice produced through numbers or excel
payment is already done through payleven mobile and must be done in person so i'd rather keep that seperate to all processes apart from a tick box to say it has been paid for.
I have been looking at all options FileMaker, Bento, Automator, Apple Script. to be frank im no expert and am a little confused as to what to do any advice would be greatly recieved.Hi,
I would suggest that is going to be an involved and complex process.
I would personally look into some of the invoicing and time scheduling software available and see if any fit your needs.
Take a look here: http://www.tuaw.com/2008/07/30/app-roundup-timekeeping-and-billing/
and here: http://www.tuaw.com/2008/07/31/app-roundup-timekeeping-and-billing-part-ii-the-q uickening/
for starters.
Best wishes
John M -
How do I reload Address Book back on to my computer
I have been difficulty with Address Book & Sycning to my phone. It completely deleted all my contacts!
And I accidently deleted the Address Book as I was following the instruction to delete files from the library pertaining to Address Book as I was instructed in a support file I found.
I would like to know if I reinstall with the CD for MAC OS 10.4.11 will it delete everything else that I already have for different programs that I use? And if I save on a disk will it retrieve back into the correct area category. Or should I burn a separate disk for (i.e. calendar, contacts, pictures, music, etc..)
I've tried restoring from off my hard drive but it cannot locate the where to restore. Any help would greatly be appreciated!Hi Mellany, and welcome to the forums!
Use the 10.4 install disc, but do not boot from it, when it mounts...
Custom installs in Mac OS X 10.4
http://docs.info.apple.com/article.html?artnum=301229
Here's a complete list of all the custom installation options available with Optional Installs.mpkg:
* Applications
o Address Book 4.0
o iCal 2.0
o iChat 3.0
o iTunes 4.7.1
o Mail 2.0
o Oxford Dictionaries
o Safari 2.0
o X11
But first, do this...
Safe Boot , (holding Shift key down at bootup), it will try to repair your Disk Directory while the spinning radian is happening, so let it go, then use Disk Utility in Applications>Utilities to Repair Permissions, then reboot when it finishes. -
I don't seem to be able to find an option for creating a Back Up for my Address Book. Earlier (10.4.x Tiger) it used to reside under the 'File' menu but i can no longer see it in Leopard. Is this a new change in the Leopard OS or should I be worried that I have a bug in the system? Any clues on how to back up my address book would be much appreciated.
Thanksthere are automated backup solutions. first of all there is Time Machine which is built in into leopard. then there are 3rd party programs like CCCloner, Superduper, Retrospect etc. see [this post|http://discussions.apple.com/thread.jspa?messageID=7495315#7495315] for more options. I would recommend any of them over a manual backup.
-
I open Address Book, go into Preferences, select Template and under the Names field (friend, assistant, father, etc) I add a custom field called "Principal".
I also add two more custom fields in the Email area.
Quit Address Book then relaunch. Add a new contact and the new custom fields, Principal, etc. are there. All good so far.
I have a Now Contact file with about 200 contacts in it. I export all fields as a Text file, Tab delimited. No problems there. With Address Book launched, select Import, pick the text file, leave Text Encoding on Automatic and click Open.
The window that shows the fields for Address Book and fields for the text file side by side opens. This is where you match up the correct fields for importing. If I go to one of the fields from the text file that I created a custom field for, click under the Address Book heading on the Do not import, scroll thru the Apple choices of fields, none of the custom fields show up. Only the original Apple ones are there. Why does Apple let you create them in the Template area but not have them available for importing? Does anyone have suggestions on getting around this?While most likely not of interest to you, Spotlight can also tell you where the files it finds are located
Hover the mouse pointer over the name, and press Command-Option and the path to the file will be displayed.
As for opening a terminal session in the directory where a file is located, there is Applescripts that do just that as well as specific features in Lion/Mountain Lion terminal:
<http://stackoverflow.com/questions/420456/open-terminal-here-in-mac-os-finder>
<http://hints.macworld.com/article.php?story=20110729034827358>
<http://www.macworld.com/article/1047793/folderinterm.html>
<http://www.macworld.com/article/1161876/open_finder_folder_in_terminal.html>
<http://www.macobserver.com/tmo/article/os_x_lion_open_a_folders_location_in_term inal> -
How to revert to yesterday's Address Book Back up?
I have deleted some contacts in error. I have multiple backups from Time Machine and want to revert to an Address Book from yesterday. Each time I try to open Address Book from a back up it appears to have been updated to the subsequent changes.
Where is the actual Address Book file stored and what is it named?
Thanks.while TM is integrated with address book and, as Kappy mentioned, you can restore individual contacts directly from TM interface while in address book this feature is extremely buggy. it's best to restore the address book database from finder. quit Address book and restore the whole folder home directory/library/application support/address book.
-
I upgraded to Snow Leopard and lost addresses in Address Book. I'm told I have 4.1.2 and can't use this version. I still have my addresses in Time Machine and it will not recover. How do I update Address Book?
Ooops!
First Timer mistake.
Sorry. -
How to sinc my address book from my apple computer to my iPad
I have an iPad mini and only have about 6 contacts showing, not sure why. I want to have my entire address book on my mini. How can I do that?
Did you sign into your iCloud account on your Mac in System Preferences>iCloud and check Contacts?
When you open Contacts (Address Book) on your Mac and go to View>Groups, are all your contacts listed under "iCloud" rather than something else like "On My Mac"?
Are you signed into your iCloud account on your iPad Mini in Settings>iCloud with Contacts set to On? -
How do I get my old e-mails and address book back?
My old computer died and I had to purchase a new one. The hard drive from the old computer is OK and I can access the files on it. What I need to do is get all my old e-mails and address book from the old hard drive and load them to Thunderbird on the new computer. I tried using the "import" feature, but it will not locate the old files. Could someone tell me where to find these files and how can I get them transferred to the new computer?
If you haven't done too much already on the new computer, you could just copy the old profile over from the old computer to the new one.
If there is already a collection of messages in the new installation, then I'd copy in the old profile, set it as default, then use the ImportExportTools add-on to import the mailbox files from the new profile, thereby bringing the old profile up to date.
https://support.mozilla.org/en-US/kb/profiles-tb?esab=a&s=profile&r=1&as=s
https://addons.mozilla.org/en-US/thunderbird/addon/importexporttools/
http://www.ramsden.org.uk/3_How_to_install_Add-ons_in_Thunderbird.html -
When I do an iCloud backup is my email address book backed up?
When I do an iCloud backup, are my email contacts backed up?
Welcome to the Apple community.
Whilst Apple do not state that it is, there is some evidence to suggest that your contact list is backed up with an iCloud backup. -
Batch Remove emails from Apple Address Book
Hi everyone,
I have a csv file contained all the email addresses that were bounced, all originating from my Address Book. This bounce file was obtained using another software (Email Bounce Handler by Maxprog).
I was now wondering if there was any way to automatize the removal of these email addresses from my Address Book, with an Apple script or any kind of extension.
Thanks in advance for your attention and your help.
Cheers,
ColinOops -- I just had to turn iCloud on in the System settings on the iPhone, then the Contacts synched.
-
Apple Script to Sort through the Address Book
Dear All,
I am quite new to Apple and just a learner on Apple-scripts. Its been quite a task to learn.. I would require some help on a few things..
The script will eventually use numbers to send email and get the user inputs and any yet to reach there..
After going through lots of scripts to sort through the address book and make a clean address book, i found they are quite slow in processing takes about 20~30 Minutes to get through 2000 Contacts..
Hence after reading posting of Mr. Koenig & Mr. Hiroto and specifically on deep copy. I have written the following code which does the following on 2000 records within 6~8Mins.
The Script work its way through all the contact is the address List.. and creates Groups
1. Duplicate Email Id's — List of Contacts with same email ID's including Contacts where the email Id is entered twice.. (Strange.. Address Book Issue, copy of the email Id under work & home)
2. Duplicate Phone — List of Contacts with same Phone Numbers including Contacts where the Phone Nos is entered twice.
3. Duplicate Name — List of Contacts with Same Names
4. Duplicate No Name — List of Contacts without the First Name and Last Name
it also sort the Contacts under the following Group which you can edit later with all the information's..
1. Only Email Ids — List of Contacts with Email ID and No Phone Numbers
2. Only Phone — List of Contacts with Phone Numbers and No Email Id's
3. No Email or Phone — List of Contacts with No Email Id's and No Phone numbers (some half completed contacts )
My Question to the forum is why is the following code still taking too much time..
set onlyDupEList to every person of group theGroupEmail
repeat with j from 1 to count of Dup_email
set tempdata to item j of Dup_email
if onlyDupEList does not contain {tempdata} then add tempdata to group theGroupEmail
end repeat
save application "Address Book"
and the scripts slows down when the items in the list is quite large (over 800 or so )..
Any help is appreciated and thanks in advance..
-- the code ---
global MsgTitle
on run
set MsgTitle to "Search for Duplicates in Address Book Contacts"
display dialog ¬
"This Script takes a while to finish" & return & "maybe 10 min or More..." & return & "Depending on the Address Book Contacts." & return & return & "Hence Allow it to run for the while" with title MsgTitle ¬
with icon 1 ¬
buttons {"Continue"} ¬
giving up after 5
set question to display dialog "Select the Duplicate Search Parameter " with icon 1 with title MsgTitle ¬
buttons {"Contact Name", "Contacts on Phone & Email Id's", "Quit"} default button 3
set rtnValue to button returned of question
if rtnValue is "Quit" then
-- tell application "Address Book" to quit
tell me to quit
end if
if rtnValue is "Contact Name" then
-- tell application "Address Book" to quit
GetDup_byName("Duplicate Name")
end if
if rtnValue is "Contacts on Phone & Email Id's" then --Contacts on Phone & Email Id's
-- tell application "Address Book" to quit
Get_dup()
end if
end run
--- Search on Name Field ---
on GetDup_byName(theGroupName)
set question to display dialog "Do you want to search for duplicates based on Names? " with icon 0 with title MsgTitle ¬
buttons {"Continue", "Quit"} default button 1
set rtnValue to button returned of question
if rtnValue is "Quit" then
-- tell application "Address Book" to quit
tell me to quit
end if
tell application "Address Book"
activate
set biglist to {}
set NoNameList to {}
set theGroupNoName to "Duplicates No Names"
set theGroup to theGroupName
-- if not (exists (group "Dupilicate Entries")) then
if not (exists (group theGroup)) then
make new group with properties {name:theGroup}
save
end if
if not (exists (group theGroupNoName)) then
make new group with properties {name:theGroupNoName}
save
end if
set the_names to name of people
repeat with i from 1 to number of items in the_names
set theName to item i of the_names
-- return theName
if theName is not in biglist then
copy theName to end of biglist
else
set counter to (people whose name is theName)
if (count of counter) > 1 then
repeat with i from 1 to number of items in counter
set this_item to item i of counter
-- display dialog this_item
add this_item to group theGroup
end repeat
-- return counter as string
end if
end if
-- captures the Contacts without Name ---
if theName contains "@" then
-- display dialog theName
set counterList to (people whose name is theName)
repeat with i from 1 to number of items in counterList
set this_item to item i of counterList
-- display dialog this_item
add this_item to group theGroupNoName
end repeat
end if
-- save application "Address Book"
end repeat
save application "Address Book"
set peopleCount to (count every person)
-- set peopleCount to 50 -- only for testing --
repeat with i from 1 to peopleCount
set first_name to first name of person i as string
set Last_Name to last name of person i as string
if first_name is equal to "missing value" and Last_Name is equal to "missing value" then
-- display dialog first_name & " : " & Last_Name
set end of NoNameList to (id of person i)
end if
end repeat
repeat with j from 1 to the count of NoNameList
set tempdata to item j of NoNameList
-- set testdata to person id tempdata
-- if (name of groups of testdata does not contain theGroupNoEmail) then
add tempdata to group theGroupNoName
-- end if
end repeat
save application "Address Book"*)
display dialog ¬
"This Script Finished Processing Address Book Contacts the Duplicates are in the group" with title MsgTitle ¬
with icon 1 ¬
buttons {"Continue"} ¬
giving up after 5
end tell
end GetDup_byName
on Get_dup()
set question to display dialog "Do you want to search for duplicates based on Names? " with icon 0 with title MsgTitle ¬
buttons {"Continue", "Quit"} default button 1
set rtnValue to button returned of question
if rtnValue is "Quit" then
-- tell application "Address Book" to quit
tell me to quit
end if
tell application "Address Book"
activate
set theGroupEmail to "Duplicate Email Id's"
set theGroupPhone to "Duplicate Phone"
set theGroupNoEmail to "Only Phone Numbers"
set thegroupNoPhone to "Only Email Id's"
set theGroupNoData to "No Email or Phone"
-- set theGroup to theGroupName
if not (exists (group theGroupEmail)) then
make new group with properties {name:theGroupEmail}
save "Address Book"
end if
if not (exists (group theGroupPhone)) then
make new group with properties {name:theGroupPhone}
save "Address Book"
end if
if not (exists (group theGroupNoEmail)) then
make new group with properties {name:theGroupNoEmail}
save "Address Book"
end if
if not (exists (group thegroupNoPhone)) then
make new group with properties {name:thegroupNoPhone}
save "Address Book"
end if
if not (exists (group theGroupNoData)) then
make new group with properties {name:theGroupNoData}
save "Address Book"
end if
set ListofPeople to people --the_ID
set ListofEmailID to value of emails of people --the_emails
-- return ListofEmailID
set ListofPhones to value of phone of people -- the_phones
-- return ListofPhones
set biglist to {}
set ListEmail_Uniq to {}
set ListEmail_Dup to {}
set No_PhoneList to {}
set No_EmailList to {}
set No_dataList to {}
set FlagEmail to false
set FlagPhone to false
-- repeat with i from 1 to number of items in the_emails
repeat with i from 1 to count of ListofEmailID
set thePersonID to item i of ListofPeople
set theEmails to item i of ListofEmailID
if theEmails is equal to {} then
set end of No_EmailList to thePersonID
else
-- set FlagEmail to true
repeat with j from 1 to count of theEmails
set tmpdata to item j of theEmails
-- return tmpdata
if tmpdata is not in biglist then
set end of biglist to tmpdata
set end of ListEmail_Uniq to {tmpdata} & {thePersonID}
else
set end of ListEmail_Dup to {tmpdata} & {thePersonID}
end if
end repeat
end if
end repeat
-- return ListEmail_Uniq
-- return ListEmail_Dup
-- save application "Address Book"
set biglist to {}
set ListPhone_Uniq to {}
set ListPhone_Dup to {}
-- repeat with i from 1 to number of items in the_emails
repeat with i from 1 to count of ListofPhones
set thePersonID to item i of ListofPeople
set thePhones to item i of ListofPhones
if thePhones is equal to {} then
set end of No_PhoneList to thePersonID
else
-- set FlagPhone to true
repeat with j from 1 to count of thePhones
set tmpdata to item j of thePhones
-- return tmpdata
if tmpdata is not in biglist then
set end of biglist to tmpdata
set end of ListPhone_Uniq to {tmpdata} & {thePersonID}
else
set end of ListPhone_Dup to {tmpdata} & {thePersonID}
end if
end repeat
end if
end repeat
-- return ListPhone_Uniq
-- return ListPhone_Dup
set the Dup_email to {}
-- Find the Duplicates from the sorted list --
repeat with i from 1 to the count of ListEmail_Dup
set tempdata to item i of ListEmail_Dup
set dataEmailDup to item 1 of tempdata
set dataPersonDup to item 2 of tempdata
repeat with j from 1 to the count of ListEmail_Uniq
set tempdata to item j of ListEmail_Uniq
set dataEmailUniq to item 1 of tempdata
set dataPersonUniq to item 2 of tempdata
-- display dialog mainEmail1 & "=" & mainEmail2 & " " & mainID1 & "=" & mainID2
if dataEmailDup is equal to dataEmailUniq then
set end of Dup_email to dataPersonDup -- & "," & dataPersonUniq
set end of Dup_email to dataPersonUniq
end if
(* -- the code takes lot more time if add to group was used --
if dataEmailDup is equal to dataEmailUniq then
set testdata to person id dataPersonDup
add testdata to group theGroup
set testdata to person id dataPersonUniq
add testdata to group theGroup
end if
end repeat
end repeat
-- return Dup_email
set the Dup_Phone to {}
-- Find the Duplicates from the sorted list --
repeat with i from 1 to the count of ListPhone_Dup
set tempdata to item i of ListPhone_Dup
set dataPhoneDup to item 1 of tempdata
set dataPersonDup to item 2 of tempdata
repeat with j from 1 to the count of ListPhone_Uniq
set tempdata to item j of ListPhone_Uniq
set dataPhoneUniq to item 1 of tempdata
set dataPersonUniq to item 2 of tempdata
-- display dialog mainEmail1 & "=" & mainEmail2 & " " & mainID1 & "=" & mainID2
if dataPhoneDup is equal to dataPhoneUniq then
set end of Dup_Phone to dataPersonDup -- & "," & dataPersonUniq
set end of Dup_Phone to dataPersonUniq
end if
(*if dataPhoneDup is equal to dataPhoneUniq then
set testdata to person id dataPersonDup
add testdata to group theGroup
set testdata to person id dataPersonUniq
add testdata to group theGroup
-- save
end if*)
end repeat
end repeat
-- return Dup_Phone
set onlyDupEList to every person of group theGroupEmail
repeat with j from 1 to count of Dup_email
set tempdata to item j of Dup_email
if onlyDupEList does not contain {tempdata} then add tempdata to group theGroupEmail
end repeat
save application "Address Book"
set onlyDupPList to every person of group theGroupPhone
repeat with j from 1 to count of Dup_Phone
set tempdata to item j of Dup_Phone
if onlyDupPList does not contain {tempdata} then add tempdata to group theGroupPhone
end repeat
save application "Address Book"
set onlyPhoneList to every person of group theGroupNoEmail
repeat with j from 1 to the count of No_EmailList
set tempdata1 to item j of No_EmailList
if No_PhoneList does not contain {tempdata1} then
if onlyPhoneList does not contain {tempdata1} then add tempdata1 to group theGroupNoEmail
end if
(*set flagE to false
repeat with i from 1 to the count of No_PhoneList
set tempdata2 to item i of No_PhoneList
if tempdata1 is equal to tempdata2 then
set flagE to true
exit repeat
end if
end repeat
if flagE is false then add tempdata1 to group theGroupNoEmail*)
end repeat
save application "Address Book"
set onlyEmailList to every person of group thegroupNoPhone
repeat with j from 1 to the count of No_PhoneList
set tempdata1 to item j of No_PhoneList
if No_EmailList does not contain {tempdata1} then
if onlyEmailList does not contain {tempdata1} then add tempdata1 to group thegroupNoPhone
end if
end repeat
save application "Address Book"
set onlyList to every person of group theGroupNoData
repeat with i from 1 to count of ListofPeople
if (item i of ListofEmailID is equal to {}) and (item i of ListofPhones is equal to {}) then
set tempdata to item i of ListofPeople
if onlyList does not contain {tempdata} then add tempdata to group theGroupNoData
end if
end repeat
save application "Address Book"
display dialog ¬
"This Script Finished Processing Address Book Contacts the Duplicates are in the group" with title MsgTitle ¬
with icon 1 ¬
buttons {"Continue"} ¬
giving up after 5
end tell
end Get_dup
on quit
--set MsgTitle to "Change Email ID's Domain Name"
save application "Address Book"
display dialog "Contact Srikanth Kamath at [email protected] for any Help" with title MsgTitle with icon 1 buttons "OK"
continue quit
end quitHello Srikanth Kamath,
I'm not sure you're still following this thread, but anyway here's sample code I said I'd post later.
--SCRIPT2
main()
on main()
script o
-- input data
property xx : {1, 2, 3, 4, 5} -- list of parents
property yy : {{"g", "h"}, {"a", "b"}, {"b", "e", "f"}, {"e"}, {"c", "d"}} -- list of children per parent
-- work list
property pp : {} -- list of children tagged by parent; i.e, lits of {child, parent}
property qq : {}
property rr : {}
-- (1) build list of children tagged by parent
repeat with i from 1 to count my xx
set x to my xx's item i
set y to my yy's item i
repeat with p in y
set end of my pp to {p's contents, x}
end repeat
end repeat
--return pp -- {{"g", 1}, {"h", 1}, {"a", 2}, {"b", 2}, {"b", 3}, {"e", 3}, {"f", 3}, {"e", 4}, {"c", 5}, {"d", 5}}
-- (2) sort tagged list by child as key
msort(my by_key1, my pp)
--return pp -- {{"a", 2}, {"b", 2}, {"b", 3}, {"c", 5}, {"d", 5}, {"e", 3}, {"e", 4}, {"f", 3}, {"g", 1}, {"h", 1}}
-- (3) retrieve parents with duplicate child
(* retrieve list of {child, parent} for duplicate child *)
set my qq to uniq(my eq_key1, my pp, {_dup:true})
--return qq -- {{"b", 2}, {"b", 3}, {"e", 3}, {"e", 4}}
(* retrieve list of parent *)
repeat with q in my qq
set r to q's item 2
if r is not in my rr then set end of my rr to r
end repeat
return rr -- {2, 3, 4}
end script
tell o to run
end main
on by_key1(x, y)
msort's comparator for list of lists
key = item 1, ascending
returns true iff x and y are out of order
return x's item 1 > y's item 1
end by_key1
on eq_key1(x, y)
uniq's comparator for list of lists
key = item 1
returns true iff x and y are considered equal
return x's item 1 = y's item 1
end eq_key1
on msort(cmp_, aa) -- v1.2f2
Basic recursive merge sort handler having list sorted in place.
handler cmp_ : comparator
* cmp_(x, y) must return true iff list element x and y are out of order.
list aa : list to be sorted in place
script o
property parent : {} -- limit closure to minimum
property xx : aa -- to be sorted in place
property xxl : count my xx
property yy : {}
property cmp : cmp_
on merge(p, q, r)
property xx: source list
integer p, q, r : absolute indices to specify range to be merged such that
xx's items p thru r is the target range,
xx's items p thru (q-1) is the first sublist,
xx's items q thru r is the second sublist.
(p < q <= r)
local i, j, k, xp, xr, yi, yj, ix, jx
if r - p = 1 then
set xp to my xx's item p
set xr to my xx's item r
if my cmp(xp, xr) then
set my xx's item p to xr
set my xx's item r to xp
end if
return -- exit
else
if p < q - 1 then merge(p, (p + q) div 2, q - 1)
merge(q, (q + r + 1) div 2, r)
end if
At this point, sublits xx[p, q-1] and xx[q, r] have been already sorted (p < q <= r)
if my cmp(my xx's item (q - 1), my xx's item q) then
else -- xx[p, q-1] & xx[q, r] are already sorted
return
end if
set yy to my xx's items p thru r -- working copy for comparison
set ix to q - p
set jx to r - p + 1
set i to 1
set j to q - p + 1
set k to p
set yi to my yy's item i
set yj to my yy's item j
repeat
if my cmp(yi, yj) then
set my xx's item k to yj
set j to j + 1
set k to k + 1
if j > jx then
set my xx's item k to yi
set i to i + 1
set k to k + 1
repeat until k > r
set my xx's item k to my yy's item i
set i to i + 1
set k to k + 1
end repeat
return
end if
set yj to my yy's item j
else
set my xx's item k to yi
set i to i + 1
set k to k + 1
if i > ix then
set my xx's item k to yj
set j to j + 1
set k to k + 1
repeat until k > r
set my xx's item k to my yy's item j
set j to j + 1
set k to k + 1
end repeat
return
end if
set yi to my yy's item i
end if
end repeat
end merge
on cmp(x, y)
(* primary comparator *)
return x > y
end cmp
local d, i, j
if xxl ≤ 1 then return
if cmp_ = {} then set my cmp to cmp -- comparator fallback
my merge(1, (xxl + 1) div 2, xxl)
end script
tell o to run
end msort
on uniq(eq_, aa, {dup:dup}) -- v0.21
handler eq_ : comparator eq_(x, y) that returns true iff x and y are considered equal
list aa : pre-sorted list
(precisely, a list organized such that any duplicate items are adjacent to each other)
boolean _dup : option whether return unique items or duplicate items
return duplicate if true, unique otherwise.
script o
property parent : {} -- limit closure to minimum
property xx : aa
property yy : {}
property eq : eq_
on eq(x, y)
(* primitive comparator *)
x = y
end eq
if eq_ = {} then set my eq to my eq -- comparator fallback
local t, x, _on
if (count my xx) < 2 then return my xx's contents
if _dup then
set _on to false
set t to my xx's item 1
repeat with i from 2 to count my xx
set x to my xx's item i
if eq(x, t) then
set end of my yy to t
set _on to true
else if _on then
set end of my yy to t
set _on to false
end if
set t to x
end repeat
if _on then set end of my yy to x
return my yy's contents -- return duplicate elements
else
set t to my xx's item 1
set end of my yy to t
repeat with i from 2 to count my xx
set x to my xx's item i
if eq(x, t) then
else
set end of my yy to x
set t to x
end if
end repeat
return my yy's contents -- return uinque elements
end if
end script
tell o to run
end uniq
--END OF SCRIPT2
In order to apply it to your current Address Book problem, replace the main() handler with something like the following one.
--SCRIPT2a (part)
on main()
script o
-- input data
property xx : {} -- list of parent; given later
property yy : {} -- list of children per parent; given later
-- work list
property pp : {} -- list of children tagged by parent; i.e, lits of {child, parent}
property qq : {}
property rr : {}
-- (0) get input data from AB
tell application "Address Book"
tell people
set xx to its id
set yy to its every email's value
end tell
end tell
-- (1) build list of children tagged by parent *)
(* omitted (same as the previous) *)
-- (2) sort tagged list by child as key
(* omitted (same as the previous) *)
-- (3) retrieve parents with duplicate child
(* omitted (same as the previous) *)
-- (4) group the retrieved people in AB
tell application "Address Book"
repeat with r in my rr
add person id r to group "duplicate email"
end repeat
end tell
end script
tell o to run
end main
--END OF SCRIPT2a
Good luck,
Hiroto
Message was edited by: Hiroto
Maybe you are looking for
-
Save Internal table to memory - problem
Hi everybody , I need to extract one Internal table to memory , every 1st in the Month . Then every day I will be reading this table for my report ( in order to avoid running every day same and same database selections) . My originall idea wos with E
-
Oracle RAC - Load Balancing Problem
Our J2EE application transactions (Container-managed) are using MULTIPLE database connections to complete one business transaction. Recently we swiched to below Oracle RAC configuration, and it is creating problems. BEA 8.1 SP5 Multi Pools Oracle 9i
-
Oracle Enterprise Manager installed but page is not loading
hi, I have installed Oracle Enterprise Manager on a Oracle Linux 5.8 box. version being Oracle.x64.11gR2. The installation was successful and I am able to start the oms services via <ORACLE_INSTALL_HOME>/middleware/oms/bin ./emctl start oms. However,
-
Errors while stopping Application 11.5.9
Dear Experts, I am facing errors while trying to stop Application services. I am using : adstpall.sh apps/pwd to stop the services and here is the log for the same. Kindly help ASAP as I need to take cold backup this weekend. Thanks in advance. Oracl
-
Someone wants to update quassel (irc)?
Is there someone, who is willing to update quassel in [community]? 0.6.1 is out. Thanks. :-)