Skip to main content

A smart file organizer that categorizes files, finds duplicates, and cleans up directories.

Project description

Smart Organizer

A command-line tool to organize files in directories by type, find duplicates, clean up empty folders, and undo operations.

Features

  • Organize Files: Automatically move files into categorized folders based on file extensions (e.g., Images, Videos, Documents).
  • Find Duplicates: Scan directories for duplicate files using SHA256 hashing.
  • Clean Up: Remove empty folders recursively.
  • Undo Operations: Reverse the last organize or clean operation.
  • Flexible Options: Recursive scanning, dry-run mode, include/exclude hidden files, logging.
  • Safe Operations: Dry-run mode to preview changes, conflict resolution for file moves.

Installation

  1. Ensure you have Python 3.8+ installed.
  2. Clone or download the repository.
  3. Install dependencies:
    pip install -r requirements.txt
    
  4. Install the package in editable mode:
    pip install -e .
    

Usage

The tool provides several commands. Run smart-organizer --help for a list of commands.

Organize Files

Moves files from the specified directory into subfolders based on their file type.

Command:

smart-organizer organize <directory_path> [options]

Options:

  • --recursive / --no-recursive: Scan and organize files in subdirectories (default: recursive).
  • --dry-run: Preview what would be moved without making changes.
  • --include-hidden: Include hidden files (starting with .) and system files.
  • --overwrite: Overwrite existing files if there are naming conflicts.
  • --log-file LOG_FILE: Save operation logs to the specified file.

Example:

smart-organizer organize /path/to/messy/folder --dry-run

This shows what files would be moved, e.g., "Would move: photo.jpg -> Images/"

smart-organizer organize /path/to/messy/folder --recursive --include-hidden --log-file organize.log

Organizes all files recursively, includes hidden files, and logs to organize.log.

Categories:

  • Images: .png, .jpg, .jpeg, .gif, .bmp, .tiff, .webp, .svg
  • Videos: .mp4, .mkv, .mov, .avi, .wmv, .flv, .webm
  • Documents: .pdf, .doc, .docx, .ppt, .pptx, .xls, .xlsx, .txt, .rtf
  • Audio: .mp3, .wav, .flac, .aac, .ogg, .wma
  • Archives: .zip, .rar, .tar, .gz, .7z, .bz2
  • Code: .py, .js, .java, .cpp, .c, .h, .html, .css, .php, .rb, .go
  • Executables: .exe, .msi, .dmg, .app, .deb, .rpm
  • Fonts: .ttf, .otf, .woff, .woff2
  • Others: Any other extensions

Find Duplicates

Scans for duplicate files based on content hash and displays them grouped.

Command:

smart-organizer duplicates <directory_path> [options]

Options:

  • --recursive / --no-recursive: Scan subdirectories (default: recursive).
  • --include-hidden: Include hidden files.
  • --log-file LOG_FILE: Save logs to file.

Example:

smart-organizer duplicates /path/to/folder --recursive

Outputs groups of duplicate files, e.g.:

Found 2 duplicate groups with 3 duplicate files:
Group 1 (Hash: abc123...):
  /path/file1.txt
  /path/file2.txt
Group 2 (Hash: def456...):
  /path/file3.jpg
  /path/file4.jpg
  /path/file5.jpg

Clean Empty Folders

Removes all empty folders recursively.

Command:

smart-organizer clean <directory_path> [options]

Options:

  • --dry-run: Preview folders that would be removed.
  • --log-file LOG_FILE: Save logs to file.

Example:

smart-organizer clean /path/to/folder --dry-run

Shows "Would remove empty folder: /path/empty/"

smart-organizer clean /path/to/folder

Removes all empty folders and reports the count.

Undo Operations

Reverses the last organize or clean operation in the directory.

Command:

smart-organizer undo <directory_path> --operation <operation> [options]

Options:

  • --operation: 'organize' or 'clean' (default: organize).
  • --log-file LOG_FILE: Save logs to file.

Example:

smart-organizer undo /path/to/folder --operation organize

Moves files back to their original locations.

smart-organizer undo /path/to/folder --operation clean

Recreates the previously removed empty folders.

Note: Undo only works for the most recent operation and requires the undo files (.smart_organizer_undo_*.json) to be present in the directory.

Show File Categories

Displays all supported file categories and their extensions.

Command:

smart-organizer info

Example Output:

File Categories:
  Images: .png, .jpg, .jpeg, .gif, .bmp, .tiff, .webp, .svg
  Videos: .mp4, .mkv, .mov, .avi, .wmv, .flv, .webm
  ...

Tips

  • Always use --dry-run first to see what will happen.
  • Use --log-file to keep a record of operations.
  • For large directories, consider running without --recursive first.
  • Undo is only available immediately after an operation; the undo files are deleted after undoing.

Requirements

  • Python 3.8+
  • Dependencies: typer, pathlib (standard library)

License

[Add license if applicable]

Show File Categories

smart-organizer info

File Categories

  • Images: .png, .jpg, .jpeg, .gif, .bmp, .tiff, .webp, .svg
  • Videos: .mp4, .mkv, .mov, .avi, .wmv, .flv, .webm
  • Documents: .pdf, .doc, .docx, .ppt, .pptx, .xls, .xlsx, .txt, .rtf
  • Audio: .mp3, .wav, .flac, .aac, .ogg, .wma
  • Archives: .zip, .rar, .tar, .gz, .7z, .bz2
  • Code: .py, .js, .java, .cpp, .c, .h, .html, .css, .php, .rb, .go
  • Executables: .exe, .msi, .dmg, .app, .deb, .rpm
  • Fonts: .ttf, .otf, .woff, .woff2
  • Others: All other file types

Examples

Organize files with dry run:

smart-organizer organize ~/Downloads --dry-run

Find duplicates in current directory:

smart-organizer duplicates . --include-hidden

Clean empty folders:

smart-organizer clean ~/Documents

License

MIT License

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

smart_organizer-1.0.1.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

smart_organizer-1.0.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file smart_organizer-1.0.1.tar.gz.

File metadata

  • Download URL: smart_organizer-1.0.1.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for smart_organizer-1.0.1.tar.gz
Algorithm Hash digest
SHA256 adfb2c0b13c33b6ad99dce403e9ac64f82a7ec4964cb20c1e378b0dbe44a570e
MD5 0fcfa2eb72051e037fd4414ee4acdeac
BLAKE2b-256 245cba40e2b78085dcbd7a4b6c1fc19ddea5c39342403362916ce1d34b18ddd1

See more details on using hashes here.

File details

Details for the file smart_organizer-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for smart_organizer-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b810d0bd883937e82ba733f843d5d29a592300b366af9c7bb1d3e33a546f51f
MD5 011c5d52fac2a6708db22711407cc882
BLAKE2b-256 dc02845f7e874c416ab5ffc97f92239ad1925aedff2aa6d91720de39bd238a77

See more details on using hashes here.

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