mdimport - macOS
Overview
mdimport is a command-line tool for importing email messages, contacts, calendars, and other data from a variety of sources into Apple Mail and Contacts. It’s particularly useful for migrating data from older email clients or when setting up a new macOS device.
Syntax
mdimport [options] [<source_file>|<source_folder>]
Options/Flags
- –type=type: Specify the data type to import. Use mail, contacts, calendars, preferences, or all. (default: all)
- –output=path: Save the imported data to a specified path.
- –from=source: Import from a specific source format. Choose from mbox, emlx, vcf, ics, or plist.
- –local=path: Convert a local mailbox to an
.mbox
file before importing. - –simulate: Perform a simulation run of the import process without making any actual changes.
- –error=path: Write errors to the specified file.
- –help: Display help information.
Examples
Import Mail from an MBOX File
mdimport ~/Documents/mail.mbox
Import Contacts from a VCF File and Save to File
mdimport --output ~/Documents/contacts.vcf --type contacts ~/Downloads/contacts.vcf
Convert a Local Mailbox to MBOX and Import
mdimport --local ~/Mail/Inbox --type mail ~/Mail/Inbox
Common Issues
- Incorrect Source Format: Ensure that the source file is in the supported format specified by the –from option.
- Insufficient Permissions: Make sure you have read permissions for the source file and write permissions for the output file (if specified).
- Duplicate Data: If importing contacts or calendars, check for duplicates before importing to avoid creating unnecessary entries.
Integration
mdimport can be integrated with AppleScript or shell scripts for automating data migration tasks. For example, you can create a script that regularly imports mail from a specified folder.
Related Commands
- Mail: Apple’s email client.
- Contacts: Apple’s contacts manager.
- Calendar: Apple’s calendar app.