Remove certain contacts from all groups

I’m Exporting from Filemaker to vCard then importing into Address Book. (fully automated)
Since I can’t ‘embed’ the group info in the vCard I have to assign the contacts to their correct group after importing.
To cut to the chase -
After importing I am removing all contacts with nickname ‘xxx’ from 4 groups, one group at a time.
Then add them to the correct group.
I have to do this 4 times for 4 different groups.
Is there a way to remove all contacts with nickname ‘xxx’ from 4 groups in one step and possibly quicker?
My current solution takes a couple of minutes to complete.

tell application “Address Book”
try
set thePeople to every person whose nickname = “Emp Active”
repeat with aThing in thePeople
set Entry_Name to name of aThing
set theid to id of person Entry_Name
remove person id theid from group “Emp Active”
end repeat
save
repeat with aThing in thePeople
set Entry_Name to name of aThing
set theid to id of person Entry_Name
remove person id theid from group “Emp Inactive”
end repeat
save
repeat with aThing in thePeople
set Entry_Name to name of aThing
set theid to id of person Entry_Name
remove person id theid from group “Client Active”
end repeat
save
repeat with aThing in thePeople
set Entry_Name to name of aThing
set theid to id of person Entry_Name
remove person id theid from group “Client Inactive”
end repeat
save
end try
end tell

delay 1

tell application “Address Book”
if group “Emp Active” exists then
else
make new group with properties {name:“Emp Active”}
save
delay 1
end if
set thePeople to every person whose nickname = “Emp Active”
repeat with aThing in thePeople
set Entry_Name to name of aThing
set theid to id of person Entry_Name
add person id theid to group “Emp Active”
end repeat
save
end tell

Browser: Safari 534.57.2
Operating System: Mac OS X (10.6)

Hi,

assuming you want to remove a person from all groups, this might be faster.
The script uses the group information of each person

tell application "Address Book"
	set thePeople to every person whose nickname is "Emp Active"
	repeat with aPerson in thePeople
		repeat with aGroup in (get groups of aPerson)
			remove aPerson from aGroup
		end repeat
	end repeat
	save
end tell

or, with a “black list”

property groupsToBeDeletedFrom : {"Emp Active", "Emp Inactive", "Client Active", "Client Inactive"}

tell application "Address Book"
	set thePeople to every person whose nickname is "Emp Active"
	repeat with aPerson in thePeople
		repeat with aGroup in (get groups of aPerson)
			if name of aGroup is in groupsToBeDeletedFrom then
				remove aPerson from aGroup
			end if
		end repeat
	end repeat
	save
end tell

Awesome, I really appreciate you taking the time to respond with some great, clear code!! Thank you Stefan, have a great day-