Skip to content

Rust CLI that organizes files by extension. Supports plan previews (JSON/CSV), dry-run, collision-safe moves, per-run JSON logs, and --undo-log.

Notifications You must be signed in to change notification settings

SH343246/file-organization-program

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File Organizer

A rust command-line tool that organizes folder files and sub-files to folders by their extension (PDFs → PDFs/, images → Images/, etc.). You can preview first, then organize, and even undo a run later.

Features

  • Organizes by file type
    Moves files into folders based on extension (e.g., PDFs → PDFs/, images → Images/). Unmapped types go to Others/.

  • Preview before changing anything

    • --plan json|csv shows the full move list via Json or CSV.
    • --dry-run prints exactly what would happen without touching files.
  • No Overwrites
    If a name already exists, the tool uses name (1).ext, name (2).ext, etc.

  • Undo any real run
    Every real run writes a JSON log under <root>/logs/…. Use --undo-log <path> (if you only want to see what will happen, use --dry-run) to move everything back.

  • Recursive scanning
    Recursively walks subfolders, and skips files that already in the right place.

  • Config-driven
    Customize destinations in config.json (ex "md": "Text", "mp4": "Videos").

  • Easy to run
    Works with one command via cargo run -- <folder>.

How to Use

  • Run on a folder
    cargo run -- /path/to/folder

  • Preview a plan (no changes)
    cargo run -- /path/to/folder --plan json
    cargo run -- /path/to/folder --plan csv

  • Dry-run (no changes)
    cargo run -- /path/to/folder --dry-run

  • Undo using a log file (folder is ignored in undo mode)
    cargo run -- /any/folder --undo-log /path/to/log.json
    cargo run -- /any/folder --undo-log /path/to/log.json --dry-run

Configuration File (config.json)

Extensions can be mapped via the configuration file. Below is an example:

{
  "pdf": "PDFs",
  "jpg": "Images",
  "jpeg": "Images",
  "png": "Images",
  "pptx": "Slides"
}

Safety

  • No overwrites If file abc.pdf exists, it becomes abc (1).pdf, then (2), etc.

  • Undo is safe. It restores in reverse order and also avoids overwriting.

About

Rust CLI that organizes files by extension. Supports plan previews (JSON/CSV), dry-run, collision-safe moves, per-run JSON logs, and --undo-log.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages