# File and Folder Organization

Labrat provides two distinct file workflows. Archiving copies a directory and creates a ZIP file. Organizing moves matching files out of the top level of `Downloads` and `Documents`.


# Create an archive

Create the destination parent first, then archive a source directory:

``` bash
mkdir -p ./archives
labrat archive \
  --source ./my_project \
  --destination ./archives \
  --name my_project
```

Labrat creates a timestamped directory such as `my_project_archive_20260905_143000` and a ZIP archive beside it. The original source remains in place.

Archive names include local time down to the second. Run archives sequentially when they share a project name and destination.


# Organize scientific files

``` bash
labrat organize --science
```

This command moves recognized scientific files from the top level of `~/Downloads` and `~/Documents` into `~/Documents/Research_Data`. Recognized formats include common sequence, alignment, variant, annotation, phylogenetic, structure, astronomy, HDF5, and NetCDF extensions.

Choose a different destination with:

``` bash
labrat organize --science --science-dir ./research-data
```

`--science-dir` selects the destination. Labrat continues scanning the top level of `~/Downloads` and `~/Documents`.


# Organize by filename or file category

``` bash
labrat organize --keyword project_alpha
labrat organize --archives
labrat organize --pictures --videos
```

Keyword matching is case-sensitive and moves matching files into `~/Documents/Organized_Files`. Archive files are grouped by compression type under `~/Documents/Archive`.

The current media implementation uses one shared organizer. Supplying either `--pictures` or `--videos` processes both recognized picture and video files.


# Review before running

> **Warning: Warning**
>
> The organize commands move files immediately. Review the top level of `~/Downloads` and `~/Documents` before running them.

If a destination already contains a file with the same name, Labrat compares modification times. It deletes the older copy and keeps the newer copy. Equal timestamps cause the source file to be deleted. Review duplicate filenames before organizing irreplaceable data.

`labrat organize --all` runs every organizer, including a keyword-specific file move. For predictable behavior, use the narrowest explicit option for the files you intend to move.

File operations are recorded under `~/.labrat/`.
