# The command line

Media Organizer brings commands for Joomla's console. They are useful above all when a scan runs into a time limit in the browser, or when you want to script maintenance.

All commands run through Joomla's CLI entry point:

```
php cli/joomla.php jimgo:scan
```

## The safety rule

<div class="callout warning" id="bkmrk-every-command-that-c">Every command that changes something is **a dry run by default**. It shows what it would do, and does nothing.

It only executes with `--confirm=<exact number>` — you have to **name the number** of files affected yourself and it has to be right. There is deliberately no `--yes`, no `--force` and no `--no-interaction` for destructive commands.

</div>The reason: a typo or an outdated script must not delete something by accident. Whoever has to name the number has looked first.

## Read-only commands

### `jimgo:scan`

Runs a complete scan. Purely reading — never writes to the file system.

```
php cli/joomla.php jimgo:scan
```

This is the recommended route for large collections: no browser time limit, no clicking to continue. Ideal as a cron job alternative to the task scheduler as well.

### `jimgo:report`

Writes the inventory to standard output.

```
php cli/joomla.php jimgo:report --format=csv --state=orphan_candidate > orphaned.csv
```

<table class="table" id="bkmrk---format%3Djson%7Ccsvout"> <tbody> <tr><td>`--format=json|csv`</td><td>Output format. Default: `json`.</td></tr> <tr><td>`--state=<state>`</td><td>Only files in this state, `orphan_candidate` for example.</td></tr> </tbody></table>

### `jimgo:duplicates`

Lists files with an identical checksum.

```
php cli/joomla.php jimgo:duplicates --limit=100
```

<table class="table" id="bkmrk---limit%3D%3Cn%3Eat-most-t"> <tbody> <tr><td>`--limit=<n>`</td><td>At most this many duplicate groups. Default: 50.</td></tr> </tbody></table>

### `jimgo:optimize`

Reports files worth optimising according to the configured thresholds.

```
php cli/joomla.php jimgo:optimize --limit=100
```

<table class="table" id="bkmrk---limit%3D%3Cn%3Eat-most-t-1"> <tbody> <tr><td>`--limit=<n>`</td><td>At most this many files. Default: 50.</td></tr> </tbody></table>

## Changing commands

### `jimgo:quarantine`

Moves the unreferenced files of the last scan to quarantine.

```
# Dry run — only shows what would happen
php cli/joomla.php jimgo:quarantine

# Execute: the number given has to match exactly
php cli/joomla.php jimgo:quarantine --confirm=42
```

### `jimgo:purge`

Deletes files in quarantine **for good**. The same twelve conditions apply as in the backend — the command line is not a back door.

```
php cli/joomla.php jimgo:purge
php cli/joomla.php jimgo:purge --confirm=17
```

### `jimgo:optimize:apply`

Optimises the flagged images. Originals are backed up beforehand.

```
php cli/joomla.php jimgo:optimize:apply
php cli/joomla.php jimgo:optimize:apply --confirm=8
```

### `jimgo:profiles:update`

Reloads the shipped extension profiles into the store. Useful after an update.

```
php cli/joomla.php jimgo:profiles:update
```

## Overview

<table class="table" id="bkmrk-commandeffectneeds--"> <thead> <tr><th scope="col">Command</th><th scope="col">Effect</th><th scope="col">Needs `--confirm`</th></tr> </thead> <tbody> <tr><td>`jimgo:scan`</td><td>reading</td><td>no</td></tr> <tr><td>`jimgo:report`</td><td>reading</td><td>no</td></tr> <tr><td>`jimgo:duplicates`</td><td>reading</td><td>no</td></tr> <tr><td>`jimgo:optimize`</td><td>reading</td><td>no</td></tr> <tr><td>`jimgo:profiles:update`</td><td>writes to the profile store only</td><td>no</td></tr> <tr><td>`jimgo:quarantine`</td><td>moves files</td><td>**yes**</td></tr> <tr><td>`jimgo:optimize:apply`</td><td>replaces images (with a backup)</td><td>**yes**</td></tr> <tr><td>`jimgo:purge`</td><td>**deletes for good**</td><td>**yes**</td></tr> </tbody></table>

## A word on automation

You *can* put `jimgo:scan` into a cron job — that is sensible and recommended.

<div class="callout warning" id="bkmrk-never-put-jimgo%3Apurg">**Never** put `jimgo:purge --confirm=…` into a cron job. The number would have to be hard-wired there, and then the script deletes a different set of files on its next run than the one you checked once. The `--confirm` rule is built precisely so that a human looks.

</div>## Where to go from here

- [Permissions, export and privacy](https://docs.graup-it.de/books/media-organizer-en/page/permissions-export-and-privacy)

<small>Applies to version 1.2.0.</small>

[Deutsche Fassung](https://docs.graup-it.de/link/73)