Skip to main content

TidyFiles is a user-friendly, lightweight CLI tool designed to bring order to your Downloads (or any other) folder! It intelligently organizes files by type and keep logs of all the sorting magic.

Project description

TidyFiles

TidyFiles Logo

PyPI - Version Python 3.10-3.13 uv Ruff codecov Tests pre-commit License: MIT Contributions Welcome

TidyFiles is a user-friendly, lightweight CLI tool designed to bring order to your Downloads (or any other) folder! It intelligently organizes files by type and keeps logs of all the sorting magic.

๐ŸŒŸ Features

  • Smart Organization: Automatically categorizes files by type (images, documents, videos, etc.)
  • Extensive Format Support & Nested Sorting: Organizes a wide variety of file types into relevant categories and subcategories (e.g., documents/ebooks, archives/installers).
  • Operation History: Track and manage all file operations with detailed history
    • View session history with source and destination directories
    • Filter history by session ID or limit number of entries
    • Detailed operation logs with timestamps and status
  • Undo Support: Revert specific operations or entire sessions safely
    • Undo individual file moves or directory deletions
    • Revert entire sessions with a single command
    • Independent operation handling - undo specific files without affecting others
    • Operation status tracking (completed, partially_undone, undone)
  • Session Management: Track operations by session with detailed status information
    • Group operations by session for better organization
    • Track session status and completion
    • View session details including source/destination paths
  • Dry Run Mode: Preview changes with --dry-run before actual organization
  • Flexible Configuration: Customize source and destination directories
  • Detailed Logging: Track all operations with console and file logging
  • Rich CLI Interface: Beautiful command-line interface with progress indicators
  • Safe Operations: Maintains file integrity during organization
  • Optional Force Mode (--force): Allow normally restricted actions (e.g., operations in protected/system directories, or overwriting files) by explicitly specifying --force on the command line. Use with caution for non-reversible actions.

๐Ÿ”ง Tech Stack

  • Core Dependencies

    • Python >=3.10: Modern Python features
    • Typer: Elegant CLI interface
    • Rich: Beautiful terminal formatting
    • Loguru: Advanced logging
    • Click: CLI framework (Typer dependency)
  • Development Tools

    • Ruff: Fast Python linter and formatter
    • Pre-commit: Automated code quality checks
    • Semantic Release: Automated versioning
  • Testing Framework

    • PyTest: Comprehensive test coverage
    • Coverage reporting: Detailed test coverage analysis

๐Ÿš€ Getting Started

Installation

pip install tidyfiles

Basic Usage

# Organize files in a specific directory
tidyfiles --source-dir /path/to/your/folder

# Undo last session if something went wrong
tidyfiles undo

Advanced Usage

  • Dry run to preview changes
tidyfiles --source-dir ~/Downloads --dry-run
  • Specify custom destination
tidyfiles --source-dir ~/Downloads --destination-dir ~/Organized
  • Custom logging
tidyfiles --source-dir ~/Downloads --log-console-level DEBUG
  • View operation history (last 10 sessions)
tidyfiles history
  • View more history entries
tidyfiles history --limit 20
  • View the last session's details
tidyfiles history --last-session
  • View detailed session information
tidyfiles history --session 3
  • Undo entire specific session
tidyfiles undo --session 3
  • Undo specific operation in a session
tidyfiles undo --session 3 --number 2
  • Force operation in protected/system directories (Dangerous!)
tidyfiles --source-dir /some/protected/folder --force
  • By default, TidyFiles will block potentially unsafe operations, such as in system directories or for non-writable files. The --force flag overrides this safety check. Use with caution.

If you decide to make cleanup you can use:

  • Clear the log file
tidyfiles --clear-log
  • Clear the entire history
tidyfiles history --clear-history

๐Ÿ“ Example Usage

Initial State

Downloads/
โ”œโ”€โ”€ photo1.jpg
โ”œโ”€โ”€ document.pdf
โ”œโ”€โ”€ video.mp4
โ”œโ”€โ”€ archive.zip
โ”œโ”€โ”€ song.mp3
โ”œโ”€โ”€ unknown.xyz
โ”œโ”€โ”€ image.iso
โ”œโ”€โ”€ script.py
โ”œโ”€โ”€ report.epub
โ”œโ”€โ”€ utility.deb
โ”œโ”€โ”€ driver.exe
โ””โ”€โ”€ Telegram Desktop/
    โ”œโ”€โ”€ photo2.jpg
    โ””โ”€โ”€ photo3.jpg

After Organization

Downloads/
โ”œโ”€โ”€ images/
โ”‚   โ”œโ”€โ”€ photo1.jpg
โ”‚   โ”œโ”€โ”€ photo2.jpg
โ”‚   โ””โ”€โ”€ photo3.jpg
โ”œโ”€โ”€ documents/
โ”‚   โ”œโ”€โ”€ document.pdf
โ”‚   โ””โ”€โ”€ ebooks/
โ”‚       โ””โ”€โ”€ report.epub
โ”œโ”€โ”€ videos/
โ”‚   โ””โ”€โ”€ video.mp4
โ”œโ”€โ”€ music/
โ”‚   โ””โ”€โ”€ song.mp3
โ”œโ”€โ”€ archives/
โ”‚   โ”œโ”€โ”€ archive.zip
โ”‚   โ”œโ”€โ”€ installers/
โ”‚   โ”‚   โ”œโ”€โ”€ windows/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ driver.exe
โ”‚   โ”‚   โ””โ”€โ”€ unix/
โ”‚   โ”‚       โ””โ”€โ”€ utility.deb
โ”‚   โ””โ”€โ”€ disk_images/
โ”‚       โ””โ”€โ”€ image.iso
โ”œโ”€โ”€ code/
โ”‚   โ””โ”€โ”€ scripts/
โ”‚       โ””โ”€โ”€ script.py
โ””โ”€โ”€ other/
    โ””โ”€โ”€ unknown.xyz

View History

$ tidyfiles history --limit 3
                                    Operation Sessions
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Session ID โ”ƒ Date       โ”ƒ Time     โ”ƒ Source                             โ”ƒ Destination                      โ”ƒ Operations โ”ƒ Status      โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚          3 โ”‚ 2025-04-04 โ”‚ 00:35:48 โ”‚ ~/Downloads                        โ”‚ ~/Organized                      โ”‚         13 โ”‚ completed   โ”‚
โ”‚          2 โ”‚ 2025-04-04 โ”‚ 00:34:12 โ”‚ ~/Documents                        โ”‚ ~/Organized                      โ”‚          3 โ”‚ completed   โ”‚
โ”‚          1 โ”‚ 2025-04-04 โ”‚ 00:32:05 โ”‚ ~/Desktop                          โ”‚ ~/Organized                      โ”‚          2 โ”‚ completed   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

View detailed session information

$ tidyfiles history --session 3

Session Details
Started: 2025-04-04 00:35:48
Source: ~/Downloads
Destination: ~/Organized
Status: completed
Operations: 13
                                                Session 3 Operations
โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ #  โ”ƒ Time     โ”ƒ Type โ”ƒ Source                                       โ”ƒ Destination                                              โ”ƒ Status    โ”ƒ
โ”กโ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚  1 โ”‚ 00:35:48 โ”‚ move โ”‚ ~/Downloads/photo1.jpg                       โ”‚ ~/Organized/images/photo1.jpg                            โ”‚ completed โ”‚
โ”‚  2 โ”‚ 00:35:48 โ”‚ move โ”‚ ~/Downloads/document.pdf                     โ”‚ ~/Organized/documents/document.pdf                       โ”‚ completed โ”‚
โ”‚  3 โ”‚ 00:35:48 โ”‚ move โ”‚ ~/Downloads/video.mp4                        โ”‚ ~/Organized/videos/video.mp4                             โ”‚ completed โ”‚
โ”‚  4 โ”‚ 00:35:48 โ”‚ move โ”‚ ~/Downloads/archive.zip                      โ”‚ ~/Organized/archives/archive.zip                         โ”‚ completed โ”‚
โ”‚  5 โ”‚ 00:35:48 โ”‚ move โ”‚ ~/Downloads/song.mp3                         โ”‚ ~/Organized/music/song.mp3                               โ”‚ completed โ”‚
โ”‚  6 โ”‚ 00:35:48 โ”‚ move โ”‚ ~/Downloads/unknown.xyz                      โ”‚ ~/Organized/other/unknown.xyz                            โ”‚ completed โ”‚
โ”‚  7 โ”‚ 00:35:48 โ”‚ move โ”‚ ~/Downloads/image.iso                        โ”‚ ~/Organized/archives/disk_images/image.iso               โ”‚ completed โ”‚
โ”‚  8 โ”‚ 00:35:48 โ”‚ move โ”‚ ~/Downloads/script.py                        โ”‚ ~/Organized/code/scripts/script.py                       โ”‚ completed โ”‚
โ”‚  9 โ”‚ 00:35:48 โ”‚ move โ”‚ ~/Downloads/report.epub                      โ”‚ ~/Organized/documents/ebooks/report.epub                 โ”‚ completed โ”‚
โ”‚ 10 โ”‚ 00:35:48 โ”‚ move โ”‚ ~/Downloads/utility.deb                      โ”‚ ~/Organized/archives/installers/unix/utility.deb         โ”‚ completed โ”‚
โ”‚ 11 โ”‚ 00:35:48 โ”‚ move โ”‚ ~/Downloads/driver.exe                       โ”‚ ~/Organized/archives/installers/windows/driver.exe       โ”‚ completed โ”‚
โ”‚ 12 โ”‚ 00:35:48 โ”‚ move โ”‚ ~/Downloads/Telegram Desktop/photo2.jpg      โ”‚ ~/Organized/images/photo2.jpg                            โ”‚ completed โ”‚
โ”‚ 13 โ”‚ 00:35:48 โ”‚ move โ”‚ ~/Downloads/Telegram Desktop/photo3.jpg      โ”‚ ~/Organized/images/photo3.jpg                            โ”‚ completed โ”‚
โ””โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Undo specific session

$ tidyfiles undo --session 3
Do you want to undo all operations in this session? [y/N]: y
โœ” Successfully undone all operations in session 3

Undo specific operation

$ tidyfiles undo --session 3 --number 1
Do you want to undo operation 1 (~/Downloads/photo1.jpg -> ~/Organized/images/photo1.jpg)? [y/N]: y
โœ” Successfully undone operation 1 in session 3

๐Ÿ“‹ Logging and History

TidyFiles maintains comprehensive logs and history:

Console Output

  • Real-time operation progress
  • Configurable log levels (DEBUG, INFO, WARNING, ERROR)
  • Rich formatting with colors and icons
  • Operation summaries and confirmations

File Logs

  • Detailed operation logs in ~/.tidyfiles/tidyfiles.log
  • Session history in ~/.tidyfiles/history.json
  • Persistent across program restarts
  • Human-readable format for easy debugging

Logging Configuration

Configure logging with various options:

# Set console log level
tidyfiles --console-log-level DEBUG

# Disable console logging
tidyfiles --no-console-log

# Configure log rotation
tidyfiles --log-rotation "100 MB" --log-retention "30 days"

# Disable file logging
tidyfiles --no-file-log

๐Ÿงฐ๏ธ Contributing

We welcome contributions! Check out our Contributing Guidelines.

๐Ÿ“„ License

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

๐ŸŽฏ Future Roadmap

  • ๐Ÿ›ˆ Info Feature Expansion: Enhance the info feature to provide detailed metadata and file information.
  • ๐ŸŒ Multi-language Interface: Switch between different languages using --lang flag for global accessibility.
  • ๐Ÿ“ Custom Categories: Define your own file categories and organization rules via simple configuration.
  • ๐Ÿ” Smart Deduplication: Intelligently detect and handle duplicate files while preserving the newest versions.
  • โœจ Advanced Renaming: Bulk rename files using patterns, dates, and custom templates.
  • ๐Ÿค– AI Organization: Use AI to categorize files based on content, not just extensions.
  • ๐Ÿ–ฅ๏ธ GUI Interface: Optional graphical interface for users who prefer visual file management.
  • โ˜๏ธ Cloud Integration: Direct organization of Dropbox and Google Drive folders.
  • โฐ Scheduled Tasks: Set up automatic organization at specified times or intervals.
  • ๐Ÿ—œ๏ธ Smart Compression: Automatically compress old or large files to save space.
  • ๐Ÿ“Š Organization Presets: Save and share your favorite organization patterns.
  • ๐Ÿ“ˆ Usage Analytics: Track space savings and organization patterns over time.
  • ๐Ÿ”„ Silent Updates: Seamless background updates with rollback support.
  • ๐ŸŽจ Terminal Themes: Customize CLI appearance with modern color schemes.
  • ๐Ÿ”” Smart Notifications: Get notified when long-running operations complete.
  • ๐Ÿ“ฑ Remote Control: Monitor and manage operations from your mobile device.

For detailed version history and latest changes, see our CHANGELOG ๐Ÿ“ˆ

๐Ÿ“Š Stats

  • First Release: March 2025
  • Latest Version: PyPI version
  • Python Compatibility: Python 3.10-3.13
  • Platform Support: Windows, macOS, Linux

Created with โค๏ธ by Serhii Ryzhaiev

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tidyfiles-0.12.0.tar.gz (115.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tidyfiles-0.12.0-py3-none-any.whl (29.9 kB view details)

Uploaded Python 3

File details

Details for the file tidyfiles-0.12.0.tar.gz.

File metadata

  • Download URL: tidyfiles-0.12.0.tar.gz
  • Upload date:
  • Size: 115.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tidyfiles-0.12.0.tar.gz
Algorithm Hash digest
SHA256 13b770059396977d5cb4332caf0dfbfc4fd27cfa4e13455fb92f22119f057bf0
MD5 0317fa8d6ce448cd717063c3f796ce85
BLAKE2b-256 2d1f02695469bbc9cefd976b4edbf1ee383bd4aa4a089481d02513a0e68dcd4b

See more details on using hashes here.

Provenance

The following attestation bundles were made for tidyfiles-0.12.0.tar.gz:

Publisher: release.yaml on RYZHAIEV-SERHII/TidyFiles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tidyfiles-0.12.0-py3-none-any.whl.

File metadata

  • Download URL: tidyfiles-0.12.0-py3-none-any.whl
  • Upload date:
  • Size: 29.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tidyfiles-0.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b8d3c944f653d5c05111f0538746b86f64511f0b36447c185610a587a090d3a9
MD5 047021871536b922f9603204306e7f54
BLAKE2b-256 61b8f82f7146b4df16052b78e3ce79fcb12ee435d432d10d53dec5ba3f44965b

See more details on using hashes here.

Provenance

The following attestation bundles were made for tidyfiles-0.12.0-py3-none-any.whl:

Publisher: release.yaml on RYZHAIEV-SERHII/TidyFiles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page