A Facebook Sync app filled the address fields of my Mac Address Book contacts with their cities. Having tons of people who have useless addresses makes it difficult to search by people on Google Maps app (ending up scrolling through many many people- I only want to see those who have proper addresses entered).
I want to clear all the home address fields in my address book using applescript. I wrote something small but couldn’t get it to work, probably needs some help from somebody who knows applescript 🙂
tell application "Address Book"
repeat with this_person in every person
repeat with this_address in every address of this_person
if label of this_address is "home" then
remove this_address from addresses of this_person
end if
end repeat
end repeat
end tell
I tried to deduct the logic of multiple addresses/phones from other scripts but could only find adding them, not removing them.
Thanks! 🙂
Your logic is sound, and would probably work if you replaced
removewithdelete, but you can shrink it even further; all that you actually need is the following simple 1.5-liner:I figured this out by looking at the “Remove Emails for Label” script from Trevor’s AppleScript Scripts, where he uses
deleteto get rid of specific email addresses (it seems likeremoveis for removing whole address cards, not pieces of them), and shrunk it with a little experimentation (which is how I find that AppleScript programming always proceeds…).