Skip to main content

fileherder

Python 3.8+ License: MIT Status: Active

Lightweight File Management Utilities

A focused Python package for essential file management operations without heavy dependencies.

Features

  • Duplicate Detection - Hash-based duplicate finding with SHA256
  • File Organization - Automatic categorization by file type
  • Batch Operations - Safe move, copy, delete, and rename operations
  • Type Detection - Smart file type classification
  • Rich CLI - Beautiful terminal interface (optional)
  • Zero Required Dependencies - Core functionality works standalone

Installation

# Basic installation (no dependencies)
pip install fileherder

# With Rich CLI (recommended)
pip install fileherder[cli]

# Development install
pip install fileherder[dev]

Quick Start

Command Line

# Find duplicate files
fileherder duplicates /path/to/directory

# Find duplicate images larger than 1MB
fileherder duplicates /photos --min-size 1048576 --extensions .jpg,.png

# Organize directory by file type
fileherder organize /downloads

# Show directory statistics
fileherder stats /data

Python API

from fileherder import FileHerder

# Create herder instance
herder = FileHerder()

# Find duplicates
duplicates = herder.find_duplicates(
    Path("/data"),
    min_size=1024*1024,  # Files larger than 1MB
    extensions={'.jpg', '.png'}  # Only images
)

for group in duplicates:
    print(f"Found {group.count} duplicates:")
    print(f"  Wasted space: {group.waste_size} bytes")
    for file_path in group.files:
        print(f"  - {file_path}")

# Organize directory
result = herder.organize(Path("/downloads"))
print(f"Organized {result.files_organized} files")
print(f"Categories: {', '.join(result.categories_created)}")

# Get statistics
stats = herder.get_statistics(Path("/data"))
print(f"Total files: {stats['total_files']}")
print(f"Total size: {stats['total_size_mb']:.2f} MB")

File Type Categories

fileherder automatically categorizes files into:

  • code - Python, JavaScript, Java, C++, etc.
  • document - PDF, DOCX, MD, TXT, etc.
  • image - JPG, PNG, GIF, SVG, etc.
  • video - MP4, AVI, MKV, MOV, etc.
  • audio - MP3, WAV, FLAC, OGG, etc.
  • archive - ZIP, TAR, GZ, 7Z, etc.
  • data - CSV, JSON, XML, SQL, etc.
  • text - Plain text, logs, config files
  • other - Uncategorized files

API Reference

Core Classes

FileHerder

Unified interface for all file management operations.

from fileherder import FileHerder

herder = FileHerder()

# Find duplicates
duplicates = herder.find_duplicates(directory, recursive=True, min_size=0)

# Organize by type
result = herder.organize(directory, dry_run=False)

# Detect file type
file_type = herder.detect_type(file_path)

# Get statistics
stats = herder.get_statistics(directory)

DuplicateFinder

Specialized duplicate file detection.

from fileherder import DuplicateFinder

finder = DuplicateFinder()
duplicates = finder.find_duplicates(
    directory,
    recursive=True,
    min_size=1024*1024,
    extensions={'.jpg', '.png'}
)

FileOrganizer

Directory organization by file type.

from fileherder import FileOrganizer

organizer = FileOrganizer()
result = organizer.organize_directory(
    directory,
    dry_run=False,
    create_subdirs=True
)

FileTypeDetector

File type classification.

from fileherder import FileTypeDetector

detector = FileTypeDetector()
file_type = detector.detect_type(Path("script.py"))
# Returns: 'code'

Batch Operations

from fileherder.operations import (
    move_files,
    copy_files,
    delete_files_safe,
    rename_files_batch
)

# Move files
result = move_files(
    files=[Path("file1.txt"), Path("file2.txt")],
    destination=Path("/archive"),
    overwrite=False
)

# Delete safely (with confirmation)
result = delete_files_safe(
    files=duplicate_files,
    require_confirmation=True
)

Data Classes

DuplicateGroup

@dataclass
class DuplicateGroup:
    hash_value: str              # SHA256 hash
    files: List[Path]            # List of duplicate files
    total_size: int              # Combined size of all
    waste_size: int              # Size of redundant copies
    count: int                   # Number of duplicates

OrganizationResult

@dataclass
class OrganizationResult:
    files_organized: int
    categories_created: List[str]
    category_counts: Dict[str, int]
    success: bool
    error: Optional[str]

Development

# Clone repository
git clone https://github.com/lukeslp/fileherder.git
cd fileherder

# Install with dev dependencies
pip install -e .[dev]

# Run tests
pytest tests/ -v

# Run tests with coverage
pytest tests/ --cov=fileherder --cov-report=html

Architecture

fileherder is designed with minimal dependencies:

  • Core module (core.py) - Pure Python, no dependencies
  • Operations module (operations.py) - Batch file operations
  • CLI module (cli.py) - Optional Rich interface

This allows the package to be used in environments where installing dependencies is difficult, while still offering a beautiful CLI when Rich is available.

Extracted from cleanupx

fileherder contains the core file management features from the larger cleanupx project, without LLM dependencies or complex integrations.

License

MIT License

Copyright (c) 2024 Luke Steuber

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Author

Luke Steuber

Metadata

Release files for fileherder 1.0.2

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

Source distribution (sdist)

Source distribution for fileherder 1.0.2
File Size Uploaded Provenance
fileherder-1.0.2.tar.gz 19.0 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 36.8 kB

Release files / fileherder-1.0.2.tar.gz

Download URL fileherder-1.0.2.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1e1fc97eb01b744403f58bf27cbadc578e4bbde9a9b3d69fd411a24dd64b6da9
BLAKE2b-256 checksum
How to use checksums
2b383da597857213ea895f53896a30a45fb832911739124cbfbb9c2c7bf6df00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / fileherder-1.0.2-py3-none-any.whl

Download URL fileherder-1.0.2-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31f5d67a2274c3d974b838a61b1d36562609aec76a09508091a9f31edc3ff784
BLAKE2b-256 checksum
How to use checksums
ea26ebe96159369e30991cd0a38d2a548aea51e7099a83d57f55d3820aa21a2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for fileherder 1.0.2

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.

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