Automating Change Address Formats for all existing Addresses in Contacts?

I live in Hong Kong and the default address format in Contacts for the Hong Kong location is based upon the Chinese language layout, i.e Country first followed by State / County & Town / City on the next line with the third line being Street.

This is fine if I input addresses in Chinese characters (which I do not). I input addresses in English and although I have set in the Contact Template that the default Address Format should be the United Kingdom and MacOS presents the blank address layout in that format (Street first followed by Town / City & County on the next line followed by Postcode Country or Region) and allows me to input in that layout, as soon as I input a telephone number with the Hong Kong Country Code it overrides the default Address Format and changes the Address Format to that for Hong Kong.

This means that all of my Hong Kong addresses appear in English but are laid out as Country first etc, Chinese layout style. I can manually change the Address Format from Hong Kong to United Kingdom. However, with over 10,000 Hong Kong addresses to change, can I automate this?

1 Like

You could export the contacts (take a backup too), manipulate them with your favourite text manipulation tools to modify the records, delete the original contacts, and then import the contacts.

For example, if you select multiple contacts, copy, then paste into Numbers (for example), you’ll see the contact data in rows and columns. you could then save out to CSV and import into Contacts. However, if you have images, associated with any contacts, then I think CSV’s would end up losing that data.

You could also use some AppleScript to do the manipulation directly on each record (again I’d take a backup first). I think this would be the approach I would take as it would leave images intact and would be a more succinct process - but the coding and testing may be more involved than just dragging columns on a spreadsheet and a bit of file saving and editing.

There are some AppleScript examples here based on batch editing that I think could be modified to read a field, store the value, read the next field, store the value and then write the two fields back the other way over - which sounds like what you’re wanting to do:

The ‘best’ approach probably depends onwhat you are most comfortable with doing, and if your contact data would survive the export-edit-import process set out as the first option.

Many thanks for this very helpful reply. As you have said it looks as though AppleScript is probably the way to go and over the next week or two I will go through the examples contained in the link that you have very kindly provided.