dji_importer.py is a small helper script for importing media from a DJI camera SD card into the macOS Photos app.
It is designed to:
- Scan an SD card for photo and video formats (JPG, MP4).
- Let you pick the SD card interactively (from
/Volumes), or provide a path directly. - Import all found media into Photos via AppleScript while asking Photos to skip already-imported items.
- macOS with the Photos app installed.
- Python 3 available as
python3in your shell. - The DJI camera is connected in SD card mode.
From the repository root:
python3 dji_importer.pyWhen called without arguments, the script:
- Scans
/Volumesfor mounted volumes. - Prints a numbered list of candidate volumes (typically including your SD card).
- Prompts you to:
- Enter a number to choose one of the listed volumes, or
- Type a custom path to your SD card (e.g.
/Volumes/DJI_SD_CARD).
After you choose the SD card, the script:
- Recursively scans for supported media files.
- Prints a summary by file type.
- Asks for confirmation before importing.
You can also pass the SD card path directly:
python3 dji_importer.py /Volumes/DJI_SD_CARDAvailable options:
-
sd_card(positional, optional)
Path to the SD card root, e.g./Volumes/DJI_SD_CARD.
If omitted, the script enters the interactive volume-selection flow described above. -
--photos-library PATH
Path to your Photos Library bundle (.photoslibrary).
Default:~/Pictures/Photos Library.photoslibrary.
This is only used to display which library will receive imports; the script does not touch its database. -
--scan-only
Only scan and print the media summary, do not import into Photos. -
-y,--yes
Skip the confirmation prompt and start importing immediately.
For each file, the script uses AppleScript:
tell application "Photos" to import POSIX file "/path/to/file" skip check duplicates trueThis means:
- Photos is responsible for detecting duplicates.
- When a file has already been imported, Photos silently skips it instead of prompting.
- You can safely re-run the script on the same SD card; already-imported items will not be duplicated.
The script prints:
- A progress line for each file:
[current/total] Import: <relative path> ... OK/Failed. - A final summary:
- Number of successfully imported files.
- Number of failed files (if any), including basic error messages from AppleScript.
- If you see repeated failures, try:
- Opening Photos manually once.
- Ensuring the SD card is readable and not locked.
- Re-running
dji_importer.pywith--scan-onlyfirst to confirm files are visible.