Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

zach-coleman

macrumors 65816
Original poster
Apr 10, 2022
1,187
2,105
A family member of mine didn’t like the default sort of the contacts app on iPhone so they put the first name in the last name field and vice versa for all of their 500+ contacts. They were unaware you could just swap it from settings. Is there any program that has been made to correct this?
 

sack_peak

Suspended
Sep 3, 2023
1,020
958
ios-16-iphone-13-pro-settings-contacts.png


Go to Settings > Contacts and choose from the following:

- Sort Order: Sort your contacts alphabetically by first or last name.
- Display Order: Show contacts' first names before or after last names.
- Short Name: Choose how your contact's name appears in apps like Mail, Messages, Phone, and more.

 

zach-coleman

macrumors 65816
Original poster
Apr 10, 2022
1,187
2,105
Go to Settings > Contacts and choose from the following: Sort Order: Sort your contacts alphabetically by first or last name. Display Order: Show contacts' first names before or after last names. Short Name: Choose how your contact's name appears in apps like Mail, Messages, Phone, and more.

This is not the problem. They have hundreds of contacts entered backwards due to their manual effort. It is an issue of bad data entry, not system settings.

Say someone’s name was John Smith. In their iPhone, they typed it as

First Name: Smith
Last Name: John

So when someone texts it says Smith John as the person who sent the message instead of John Smith.
 
Last edited:

sack_peak

Suspended
Sep 3, 2023
1,020
958
This is not the problem. They have hundreds of contacts entered backwards due to their manual effort. It is an issue of bad data entry, not system settings.

Say someone’s name was John Smith. In their iPhone, they typed it as

First Name: Smith
Last Name: John

So when someone texts it says Smith John as the person who sent the message instead of John Smith.
I am providing a creative solution to your problem that is already built into iPhone.

You want the names to appear Last Name, First Name.

Then change the way Contacts shows it from First Name Last night.

No need to write scripts or import/export/import.
 

zach-coleman

macrumors 65816
Original poster
Apr 10, 2022
1,187
2,105
I somehow decided that writing a Python script was easier than trying to convert a vcf into a csv (would be as easy as changing the file extension…) and fixed it. On the bright side, it also allowed me to fix the company info being in the last name in parentheses too. I didn’t realize it was just raw text when I first posted. I’ll upload it later in case it comes in handy for anyone else.
 
Last edited:
  • Like
Reactions: primarycolors

zach-coleman

macrumors 65816
Original poster
Apr 10, 2022
1,187
2,105
Python:
### Select all contacts in Contacts.app, select export to vCard.
### It will generate one big file with all contacts.
### [MAKE SURE TO MAKE A BACKUP OF THIS CONTACTS.VCF FILE!!]

### When finished, delete all contacts then import "output.vcf" into Contacts.app.

### BEFORE EXAMPLE
### First Name: Appleseed
### Last Name: John (Apple)
### Company:

### AFTER EXAMPLE:
### First Name: John
### Last Name: Appleseed
### Company: Apple

input_file_path = "edit.vcf"
output_file_path = "output.vcf"

with open(input_file_path, "r") as input_file:
    file_content = input_file.read()

to_delete = []

file_content = file_content.split("\n")
for i in range(len(file_content)):
    if "N:" in file_content[i] and "FN:" not in file_content[i] and "ON:" not in file_content[i] and "IN:" not in file_content[i]:
        #print(i)
        name_str = file_content[i]
        name_str = name_str.replace("N:","")
        name_str = name_str.split(";")
        print(name_str)
        for j in range(len(name_str)):
            name_str[j] = name_str[j].strip()
        temp = name_str[0]
        temp = temp.replace(")", "")
        temp = temp.split("(")
        print(temp)
        if len(temp) > 1:
            occupation = temp[1]
        else:
            occupation = ""
        name_str[0] = name_str[1]
        name_str[1] = temp[0]
        name_str = "N:"+name_str[0] + ";" + name_str[1] + ";;;\n"+"ORG:"+occupation
        print(name_str)
        file_content[i] = name_str
    if "FN:" in file_content[i]:
        to_delete.append(i)

to_delete = to_delete[::-1]
for i in to_delete:
    del file_content[i]

output = "\n".join(file_content)

# Open the output file for writing
with open(output_file_path, "w") as output_file:
    output_file.write(output)

print(f"File '{input_file_path}' has been edited and saved as '{output_file_path}'.")

If anyone stumbles upon this in the future and requires assistance, I'll attempt to help. This could absolutely be cleaned up but it did the job so what's the point.
 
  • Like
Reactions: primarycolors
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.