# `mix phoenix_kit.cleanup_orphaned_files`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v2.40.1/lib/mix/tasks/phoenix_kit.cleanup_orphaned_files.ex#L1)

Finds orphaned media files in PhoenixKit Storage and optionally moves them
to the trash.

An orphaned file is one not referenced by any known entity (products, posts,
categories, users, publishing content, etc.).

By default this task runs in dry-run mode and only reports what it found.
Use `--delete` to queue them, via Oban, to be moved to the trash. Nothing
is deleted outright: a trashed file can be restored until the daily trash
prune deletes it after `trash_retention_days`.

## Usage

    $ mix phoenix_kit.cleanup_orphaned_files
    $ mix phoenix_kit.cleanup_orphaned_files --delete

## Options

  * `--delete` - Queue orphaned files to be moved to the trash (default: dry-run)

## Examples

    # Dry-run: show orphaned files without touching them
    mix phoenix_kit.cleanup_orphaned_files

    # Move all orphaned files to the trash
    mix phoenix_kit.cleanup_orphaned_files --delete

---

*Consult [api-reference.md](api-reference.md) for complete listing*
