Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,49 +73,50 @@ All commands support a `--dry-run` flag. Use this to safely preview changes befo
- No directories are created
- Actions are only printed

**All commands currently process files in the top-level input directory only.**

#### organise-by-date
#### by-date

- Organise images into date-based folders (`YYYY-MM-DD`, optional suffix)
- Files are moved (not copied) into the output directory
- If a destination file already exists, it is skipped (no overwrite)

```shell
photo-tools organise-by-date <INPUT_DIR> <OUTPUT_DIR>
photo-tools by-date <INPUT_DIR> <OUTPUT_DIR>
```
```shell
photo-tools organise-by-date <INPUT_DIR> <OUTPUT_DIR> --suffix <SUFFIX>
photo-tools by-date <INPUT_DIR> <OUTPUT_DIR> --suffix <SUFFIX>
```
```shell
photo-tools organise-by-date <INPUT_DIR> <OUTPUT_DIR> --dry-run
photo-tools by-date <INPUT_DIR> <OUTPUT_DIR> --dry-run
```

#### separate-raws
#### raws

- Move RAW images into a `raws/` subfolder within the input directory
- Non-RAW files are left unchanged
- Files are moved (not copied) in place
- If a destination file already exists, it is skipped (no overwrite)

```shell
photo-tools separate-raws <INPUT_DIR>
photo-tools raws <INPUT_DIR>
```
```shell
photo-tools separate-raws <INPUT_DIR> --dry-run
photo-tools raws <INPUT_DIR> --dry-run
```

#### clean-unpaired-raws
#### clean-raws

- Move RAW files to `raws-to-delete/` if no matching JPG (same prefix) exists
- Matching is based on filename prefix (e.g. `abcd.RAF` matches `abcd_edit.jpg`)
- Files are moved (not deleted), making the operation reversible

```shell
photo-tools clean-unpaired-raws <RAW_DIR> <JPG_DIR>
photo-tools clean-raws <RAW_DIR> <JPG_DIR>
```

```shell
photo-tools clean-unpaired-raws <RAW_DIR> <JPG_DIR> --dry-run
photo-tools clean-raws <RAW_DIR> <JPG_DIR> --dry-run
```

#### optimise
Expand Down
14 changes: 7 additions & 7 deletions src/photo_tools/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,33 @@ def main() -> None:
setup_logging()


@app.command("organise-by-date")
@app.command("by-date")
def organise_by_date_cmd(
input_dir: str = typer.Argument(
...,
help="Directory containing input images",
help="Directory containing input images.",
),
output_dir: str = typer.Argument(
...,
help="Directory where organised images will be saved",
help="Directory where organised images will be saved.",
),
suffix: str | None = typer.Option(
None,
"--suffix",
help="Optional suffix appended to folder names (e.g. location)",
help="Optional suffix appended to folder names (e.g. location).",
),
dry_run: bool = typer.Option(
False,
"--dry-run",
help="Preview changes without moving files",
help="Preview changes without moving files.",
),
) -> None:
"""Organise images into folders based on capture date."""
organise_by_date(input_dir, output_dir, suffix, dry_run)


@app.command(
"separate-raws",
"raws",
help="Move RAW images into a 'raws' folder",
)
def separate_raws_cmd(
Expand All @@ -69,7 +69,7 @@ def separate_raws_cmd(


@app.command(
"clean-unpaired-raws",
"clean-raws",
help="Move RAW files without matching JPGs to 'raws-to-delete'.",
)
def clean_unpaired_raws_cmd(
Expand Down
6 changes: 3 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def fake_which(_):

monkeypatch.setattr("shutil.which", fake_which)

result = runner.invoke(app, ["organise-by-date", "in", "out"])
result = runner.invoke(app, ["by-date", "in", "out"])

assert result.exit_code == 1
assert "Error:" in result.output
Expand Down Expand Up @@ -49,7 +49,7 @@ def test_organise_by_date_command_moves_file(tmp_path, monkeypatch):

result = runner.invoke(
app,
["organise-by-date", str(input_dir), str(output_dir)],
["by-date", str(input_dir), str(output_dir)],
)

assert result.exit_code == 0
Expand All @@ -74,7 +74,7 @@ def test_organise_by_date_command_dry_run_does_not_move_file(tmp_path, monkeypat

result = runner.invoke(
app,
["organise-by-date", str(input_dir), str(output_dir), "--dry-run"],
["by-date", str(input_dir), str(output_dir), "--dry-run"],
)

assert result.exit_code == 0
Expand Down
Loading