An attempt to use Qwen3-code and its cli (that has a very generous free tier) to create a ratatui application that allows to reorganize files by date and named time range.
Find a file
2025-09-27 22:03:17 +08:00
src Enhance file list preview with better navigation and cleaner paths 2025-09-27 22:03:17 +08:00
tasks Enhance file list preview with better navigation and cleaner paths 2025-09-27 22:03:17 +08:00
.gitignore initial version after a bit of interactive fixing in Qwen 2025-09-25 23:21:40 +08:00
Cargo.lock implement basic theming system, fix contrast 2025-09-27 21:04:32 +08:00
Cargo.toml implement basic theming system, fix contrast 2025-09-27 21:04:32 +08:00
QWEN.md add general advice for Rust projects (read docs, check examples..) 2025-09-27 14:42:21 +08:00
README.md initial version after a bit of interactive fixing in Qwen 2025-09-25 23:21:40 +08:00

re-sort

A command-line and interactive terminal-based application for organizing files based on their modification dates and custom time ranges. Built with Rust and the ratatui crate for a text-based user interface (TUI).

Features

  • Date-based file organization: Automatically sorts files into dated directories based on their modification time
  • Custom time ranges: Define your own time buckets with names (e.g., "insomnia" for 2-8 AM, "work" for 9-5 PM)
  • Multiple operation modes: Move, copy, or create symbolic links
  • Preview mode: See how files will be organized before executing
  • Interactive TUI: Easy-to-use terminal interface with keyboard navigation
  • Non-interactive mode: Command-line only operation for automation
  • Recursive scanning: Option to include subdirectories

Installation

# Clone the repository
git clone https://github.com/your-username/re-sort.git
cd re-sort

# Build the project
cargo build --release

# Run directly with Cargo
cargo run -- [options]

Usage

Interactive Mode

Simply run the application without any arguments to start the interactive TUI:

cargo run

Non-Interactive Mode

# Basic usage
re-sort --source /path/to/source --target /path/to/target --ranges "2:00..8:00:insomnia,9:00..12:00:morning,13:00..18:00:afternoon,19:00..25:00:night" --format "%Y-%m-%d" --mode move

# With recursive scanning
re-sort --source /path/to/source --target /path/to/target --ranges "2:00..8:00:insomnia,9:00..12:00:morning" --recursive

# Only process specific file extensions
re-sort --source /path/to/source --target /path/to/target --ranges "9:00..17:00:work" --extensions ".jpg,.png,.gif"

CLI Options

  • --source: Source directory to scan for files (default: current directory)
  • --target: Target directory for organized files (default: current directory)
  • --ranges: Time ranges with names (e.g., "2:00..8:00:insomnia,9:00..12:00:morning")
  • --format: Date format for directory names (default: "%Y-%m-%d")
  • --mode: Operation mode (move, copy, symlink) (default: move)
  • --recursive: Enable recursive scanning of subdirectories
  • --extensions: File extensions to include (comma-separated, e.g., ".jpg,.png")
  • --non-interactive: Run in non-interactive mode (command-line only)

Time Range Format

Time ranges are specified as:

  • HH:MM..HH:MM:name for basic ranges (e.g., "2:00..8:00:insomnia")
  • HH:MM:SS..HH:MM:SS:name for ranges with seconds (e.g., "2:00:30..8:15:45:insomnia")
  • Ranges can cross midnight using hours > 24 (e.g., "23:00..25:30:night" means 11 PM to 1:30 AM next day)

Multiple ranges are comma-separated: "2:00..8:00:insomnia,9:00..12:00:morning,13:00..18:00:afternoon"

Navigation in TUI

  • Enter: Confirm selection or proceed to next step
  • q: Quit application
  • j/k: Navigate through file lists in preview mode
  • Arrow keys: Navigate UI elements

Examples

Organize images from a download folder into daily directories with custom time ranges:

re-sort --source ~/Downloads --target ~/Organized --ranges "2:00..8:00:sleep,8:00..12:00:morning,12:00..18:00:afternoon,18:00..24:00:evening" --format "%Y-%m-%d" --extensions ".jpg,.png,.gif" --mode move --recursive

Architecture

The application is organized into the following modules:

  • src/main.rs: CLI entry point and TUI launcher
  • src/core/parser.rs: Time range and date format parsing
  • src/core/organizer.rs: File discovery, grouping, and execution logic
  • src/tui/app.rs: Terminal user interface implementation

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License - see the LICENSE file for details.