Skip to main content

Extensort

Extensort is a Python module that simplifies the process of organizing files by sorting them into folders based on their extensions. It provides an efficient way to clean up cluttered directories and maintain a well-organized file system.

Features

  • Automatically sort files into folders based on their extensions
  • Customizable mapping of file extensions to folder names
  • Find all unique file extensions in a directory
  • Detailed sorting summary including moved, skipped, and error counts
  • Color-coded console output for better visibility of the sorting process

Installation

You can install Extensort using pip:

pip install extensort

Usage

Here's a quick example of how to use Extensort:

from extensort import sort_files, find_extensions

# Define the directory to sort
directory_to_sort = "/path/to/your/directory"

# Find all extensions in the directory
all_extensions = find_extensions(directory_to_sort)
print(f"Found extensions: {all_extensions}")

# Define how you want to sort the files
extension_mapping = {
    ".txt": "Text Files",
    ".pdf": "Documents",
    ".jpg": "Images",
    ".png": "Images",
    ".py": "Python Scripts"
}

# Sort the files
summary = sort_files(directory_to_sort, extension_mapping)

print("Sorting complete!")
print(f"Moved: {summary['moved']}")
print(f"Skipped: {summary['skipped']}")
print(f"Errors: {summary['errors']}")

Detailed Usage

Finding Extensions

The find_extensions function scans a directory and returns a set of all unique file extensions:

extensions = find_extensions("/path/to/directory")

Sorting Files

The sort_files function organizes files into folders based on their extensions:

extension_mapping = {
    ".txt": "Text",
    ".jpg": "Images",
    ".png": "Images",
    ".docx": "Documents",
    ".pdf": "Documents",
    ".py": "Code",
    ".js": "Code"
}

summary = sort_files("/path/to/sort", extension_mapping)

The function returns a summary dictionary with the following keys:

  • moved: Number of files successfully moved
  • skipped: Number of files skipped (no matching extension in the mapping)
  • errors: Number of errors encountered during the sorting process

Contributing

Contributions to Extensort are welcome! Please feel free to submit a Pull Request.

License

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

Metadata

Release files for extensort 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for extensort 0.1.1
File Size Uploaded Provenance Actions
extensort-0.1.1.tar.gz 3.7 kB Without provenance Details for extensort-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for extensort 0.1.1
File Interpreter ABI Platform Actions
extensort-0.1.1-py3-none-any.whl Python 3 none any Details for extensort-0.1.1-py3-none-any.whl

Total release size: 7.9 kB

Release files / extensort-0.1.1.tar.gz

Download URL extensort-0.1.1.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
734bf11db81d8f8f01acc2d8d1d18631d4ccd3ef701af4e67eb035ac9177fdb7
BLAKE2b-256 checksum
How to use checksums
5ab12b83eadaf20e9e03cfa95518cdf8a507c4ed27d182aa00898a15dd19d9d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.2

Release files / extensort-0.1.1-py3-none-any.whl

Download URL extensort-0.1.1-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0549c4e4bb1fc88a5dd664da0c0bb90afece5d0a59eea9a3bec83126e1dd557f
BLAKE2b-256 checksum
How to use checksums
abfabfe3c4c0de6d6e4ae0cb7623e9560732e5b21b1485234f7122a7ab6f8729
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.2

Security for extensort 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page