Skip to content

Import Existing

rhoopr edited this page May 2, 2026 · 7 revisions

import-existing

Scan a local directory and mark matching iCloud assets as already downloaded in the state database. The next sync skips these files instead of re-downloading them.

Usage

kei import-existing -u my@email.address -d /photos

This authenticates with iCloud, enumerates the library, then walks the download directory matching local files to remote assets by filename and size. Matched files are recorded as downloaded in the state DB.

When to Use

  • Migrating from Python icloudpd (or any other tool) that already downloaded your library
  • Recovering after a database reset when the files are still on disk
  • Adopting kei on a directory that was populated by another method

See Migration from Python for the full migration workflow.

Flags

Global flags (--username, --config, --data-dir, --domain, --log-level) apply to this command.

Flag Description
-d, --download-dir Local directory containing existing files (required)
--library Library zone(s) to match against. Repeatable in v0.13; same grammar as kei sync --library.
--album Album selector. Repeatable in v0.13; same grammar as kei sync --album.
--smart-folder Smart-folder selector. Repeatable; same grammar as kei sync --smart-folder.
--unfiled Toggle the unfiled pass (default: true).
--folder-structure Unfiled-pass template (default: %Y/%m/%d)
--folder-structure-albums Album-pass template (default: {album}). New in v0.13.
--folder-structure-smart-folders Smart-folder-pass template (default: {smart-folder}). New in v0.13.
--file-match-policy Filename deduplication policy. Must match the original download.
--size Size variant the original tree was downloaded with
--live-photo-mode Live-photo handling used at original download
--live-photo-size Live-photo size used at original download
--live-photo-mov-filename-policy MOV filename style used at original download
--align-raw RAW alignment policy used at original download
--force-size Force-size used at original download
--keep-unicode-in-filenames Must match the setting used during the original download
--force-empty Override the empty-library guard (rare; only when you genuinely emptied a library)
--recent Only check the N most recent assets
--no-progress-bar Disable the progress bar
-p, --password iCloud password
--password-file Read password from a file
--password-command Run a command to get the password

import-existing derives expected paths via the same chain kei sync uses (CLI > env > TOML > default), so --folder-structure*, --file-match-policy, --keep-unicode-in-filenames, and the size/live-photo flags must match what produced the files on disk. If the folder layout doesn't match, files end up in the unmatched bucket and re-download on the next sync.

If you're adopting a tree previously synced under v0.12 defaults, point --folder-structure-albums at the v0.12 layout ({album}/%Y/%m/%d) or move the files into the v0.13 default shape ({album}/... flat) before running import.

Related

Clone this wiki locally