Skip to main content

Sort files by extension or category from the command line

Project description

███████╗ ██████╗ ██████╗ ████████╗███████╗██████╗
██╔════╝██╔═══██╗██╔══██╗╚══██╔══╝██╔════╝██╔══██╗
█████╗  ██║   ██║██████╔╝   ██║   █████╗  ██████╔╝
██╔══╝  ██║   ██║██╔══██╗   ██║   ██╔══╝  ██╔══██╗
██║     ╚██████╔╝██║  ██║   ██║   ███████╗██║  ██║
╚═╝      ╚═════╝ ╚═╝  ╚═╝   ╚═╝   ╚══════╝╚═╝  ╚═╝

Organise your Chaos : a CLI tool to sort files by extension or category (list of extensions in by genre), with recursive mode, the choice between copy/move, and a way to run in the background that watches folders in real time and auto-sorts according to the user's needs.

Requirements :

Python 3.7 + (with pip)
macOS / Linux (Windows not supported due to daemon mode)

Installation :

From my github repo :

Run these commands :

    git clone https://github.com/yourusername/filesorter.git
    cd filesorter
    pip install -e .

Or directly with pip :

    pip install panda-filesorter

Usage :

FORMAT :
    filesorter <command> [arguments]

COMMANDS :

    sort <path/to/directory/that/needs/sorting> <category/filetype> <path/to/destinationDirectory> - single-time sorting (if destinationDirectory does not exist it will be created)
    watch <path/to/directory/that/needs/sorting> <category/filetype> <path/to/destinationDirectory> - continuously watch a directory and sort new files
    stop <path/to/watchedDirectory> - stop a background watcher

    HINT : use a command with only the -h flag to get help :

FLAGS :

    --recursive, -r       : Process subfolders (sort command only)
    --copy                : Copy files instead of moving (default is move)
    --background, -bg     : Run watch as background daemon (So you dont need to keep it running)
    --type EXT, -t        : Sort by a single extension (e.g. .png)
    --category CAT, -c    : Sort by predefined category (see table below)


EXAMPLES :
    filesorter sort --help      -> Gets help and format for sort command
    filesorter sort ~/Desktop ~/Documents --type .pdf --copy -> Takes all pdfs in the Desktop folder and copies them to the Documents folder
    filesorter watch ~/Desktop ~/Screenshots --category img --background -> Continuously moves all image files in the Desktop folder into the Screenshots folder in the background

CATEGORIES :
    img : .jpg, .jpeg, .png, .gif, .bmp, .tiff, .webp, .svg, .ico
    doc : .pdf, .docx, .doc, .txt, .md, .rtf, .odt, .tex
    video : .mp4, .mov, .avi, .mkv, .flv, .wmv, .webm
    audio : .mp3, .wav, .flac, .aac, .ogg, .m4a
    archive : .zip, .tar, .gz, .rar, .7z, .bz2, .xz
    code : .py, .js, .html, .css, .cpp, .c, .java, .go, .rs, .php, .rb, .swift, .kt
    spreadsheet : .xlsx, .xls, .csv, .ods
    presentation : .pptx, .ppt, .key, .odp
    executable : .exe, .msi, .app, .deb, .rpm, .sh, .bat
    diskimage : .iso, .img, .dmg
    font : .ttf, .otf, .woff, .woff2
    ebook : .epub, .mobi, .azw, .fb2
    cad : .dwg, .dxf, .stl, .obj
    database : .db, .sqlite, .sql, .mdb
    config : .json, .yaml, .yml, .xml, .toml, .ini, .cfg

Command not found after install?

If you run filesorter and get command not found, the Python scripts directory is not in your PATH.

Fix (macOS / Linux):

  1. Find where Python installs scripts:
    python3 -m site --user-base
    Then add /bin to that path (e.g., /Users/you/Library/Python/3.10/bin)
    

Add this line to your ~/.zshrc or ~/.bashrc:

export PATH="$PATH:/path/to/python/bin"

Reload your shell:

source ~/.zshrc

Or use the module directly:

python3 -m filesorter --help

This Project was created from scratch for the Stardance coding event by Hack Club inc.

Specific flags for commands (again)

filesorter sort <source_dir> <dest_dir> [flags]

Flags specific to sort:

  • --type EXT, -t – sort by a single extension (e.g. .pdf)
  • --category CAT, -c – sort by a predefined category
  • --recursive, -r – process subfolders
  • --copy – copy instead of move (default is move)

watch – continuous monitoring

Flags specific to watch:

  • --type EXT, -t – watch for a single extension
  • --category CAT, -c – watch for a category
  • --copy – copy instead of move
  • --background, -bg, -b – run as a background daemon

stop – stop a background watcher

Summary table

Flag sort watch stop
--type, -t
--category, -c
--recursive, -r
--copy
--background, -bg, -b

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

panda_filesorter-0.3.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

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

panda_filesorter-0.3.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file panda_filesorter-0.3.0.tar.gz.

File metadata

  • Download URL: panda_filesorter-0.3.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.1

File hashes

Hashes for panda_filesorter-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f9ddfb04a5204ca1f214254e9593ce168c77108514aaf43931d1e971474c8d36
MD5 97dafdf9f4b3b70bf220c9194c57e87e
BLAKE2b-256 7ce242a362341fe2a39283de392aea7c579dc118262d72693802d9ae574ba14a

See more details on using hashes here.

File details

Details for the file panda_filesorter-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for panda_filesorter-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 344288d1170f9314634494fca5ac9b6fb4e98e14985e294e62bb337d134ae345
MD5 f6dc54018ebca5f1c94a3670442376ba
BLAKE2b-256 44d93e7b3e98c84655eef0756fb8af6578e85bf4c1cf01bff018bb4884ef8936

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