An open API service indexing awesome lists of open source software.

https://github.com/basantsd/smart-file-organizer-cli

A fast, flexible, and safe command-line tool built in Rust to automatically organize messy folders into structured directories using customizable rules.
https://github.com/basantsd/smart-file-organizer-cli

anyhow cargo clap-rs directory indicatif rust serde toml

Last synced: about 2 months ago
JSON representation

A fast, flexible, and safe command-line tool built in Rust to automatically organize messy folders into structured directories using customizable rules.

Awesome Lists containing this project

README

          

# Smart File Organizer CLI (Rust)

![Rust](https://img.shields.io/badge/Rust-000000?style=for-the-badge&logo=rust&logoColor=white)

## πŸ“Έ Demo

### Before: Unorganized Files
![Unorganized Files](./demo/1-unorganized-files.png)

### Checking Dry Run
![Check Dry Run](./demo/2-check-dry-run.png)

### Moving Files
![Move Files](./demo/3-move-files.png)

### After: Organized Files
![Files Organized](./demo/4-file-organized.png)

A fast, flexible, and safe command-line tool built in Rust to automatically organize messy folders into structured directories using customizable rules.

---

## Why This Project?

Most people’s **Downloads folder is chaos** β€” images, PDFs, videos, code files all mixed together.

This tool solves that problem by:

* Scanning your folders automatically
* Applying smart, customizable rules
* Organizing files into clean, structured directories
* Doing it safely with preview (dry-run) support

---

## Features

* βœ… Recursive file scanning
* βœ… Rule-based file organization (via TOML config)
* βœ… Dry-run mode (preview before moving files)
* βœ… Safe file handling (no overwrites)
* βœ… Progress bar for real-time feedback
* βœ… Cross-platform support (Linux, macOS, Windows)
* βœ… Clean error handling (no crashes)

---

## How It Works

1. You provide a folder (e.g., Downloads)
2. The tool scans all files recursively
3. It applies rules defined in a config file
4. Files are moved into categorized folders

---

## Example Usage

```bash
# Preview (safe mode)
smart-organizer ~/Downloads --dry-run

# With custom config
smart-organizer ~/Downloads --config config.toml

# Actual execution
smart-organizer ~/Downloads
```

---

## Configuration (TOML)

Create a `config.toml` file:

```toml
[[rules]]
name = "Images"
extensions = ["jpg", "png", "jpeg"]
destination = "Images"

[[rules]]
name = "Documents"
extensions = ["pdf", "docx", "txt"]
destination = "Documents"

[[rules]]
name = "Reports"
extension = "csv"
starts_with = "report_"
destination = "Data"
```

---

## πŸ§ͺ Dry Run Example

```bash
smart-organizer ~/Downloads --dry-run
```

Output:

```
[DRY RUN] photo.jpg β†’ Images/
[DRY RUN] report_2024.csv β†’ Data/
```

---

## πŸ“Š Real Execution Example

```
βœ… Moved β†’ Downloads/Images/photo.jpg
βœ… Moved β†’ Downloads/Documents/file.pdf
⚠️ Skipped (already exists)
```

---

## Project Structure

```
src/
β”œβ”€β”€ main.rs # Entry point
β”œβ”€β”€ cli.rs # CLI argument parsing
β”œβ”€β”€ scanner.rs # File scanning logic
β”œβ”€β”€ config.rs # Config loader (TOML)
β”œβ”€β”€ rules.rs # Rule engine (core logic)
β”œβ”€β”€ mover.rs # File moving logic
β”œβ”€β”€ progress.rs # Progress bar UI
```

---

## Tech Stack

* Rust πŸ¦€
* clap β€” CLI parsing
* walkdir β€” directory traversal
* serde + toml β€” config parsing
* anyhow β€” error handling
* dirs β€” system config paths
* indicatif β€” progress bar

---

## πŸ›‘οΈ Safety Features

* βœ” Dry-run mode (preview before execution)
* βœ” No file overwrite (skips duplicates)
* βœ” Graceful error handling
* βœ” Controlled file movement

---

## Installation

```bash
cargo build --release
```

Run:

```bash
./target/release/smart-file-organizer ~/Downloads
```

---

## πŸ‘¨β€πŸ’» Author

Built by Basant Singh using Rust to solve a real-world problem.

---

## ⭐ Support

If you like this project, consider giving it a ⭐ on GitHub!