API Reference
This document provides detailed information about the OrganiserPro API. It’s intended for developers who want to extend or modify the functionality of OrganiserPro.
Core Modules
- OrganiserPro.cli.sort_by_type_cmd(directory: str, dry_run: bool = False) int[source]
Legacy function for sort by type functionality.
- OrganiserPro.cli.sort_by_date_cmd(directory: str, date_format: str, dry_run: bool = False) int[source]
Legacy function for sort by date functionality.
- OrganiserPro.cli.sort_by_size_cmd(directory: str, dry_run: bool = False) int[source]
Legacy function for sort by size functionality.
- OrganiserPro.cli.dedupe_cmd(directory: str, recursive: bool = True, delete: bool = False, move_to: str | None = None, dry_run: bool = False) int[source]
Legacy function for dedupe functionality.
- OrganiserPro.dedupe.get_file_hash(file_path: Path, block_size: int = 65536) str[source]
Generate a hash for a file to uniquely identify its contents.
- Parameters:
file_path – Path to the file
block_size – Size of chunks to read at once
- Returns:
SHA-256 hash of the file contents
- Return type:
- OrganiserPro.dedupe.find_duplicates(directory: str, recursive: bool = False) Dict[str, List[Path]][source]
Find duplicate files in the given directory.
- Parameters:
directory – Directory to search for duplicate files
recursive – If True, search recursively in subdirectories
- Returns:
Dict mapping file hashes to lists of duplicate file paths
- OrganiserPro.dedupe.handle_duplicates(duplicates: Dict[str, List[Path]], delete: bool = False, move_to: str | None = None) None[source]
Handle duplicate files by printing, deleting, or moving them.
- Parameters:
duplicates – Dictionary mapping file hashes to lists of duplicate files
delete – If True, delete all but the first file in each duplicate set
move_to – If provided, move duplicates to this directory instead of deleting
- OrganiserPro.dedupe.find_duplicates_cli(directory: str, recursive: bool = False, delete: bool = False, move_to: str | None = None, dry_run: bool = False) None[source]
CLI interface for finding and handling duplicate files.
- Parameters:
directory – Directory to search for duplicate files
recursive – If True, search subdirectories recursively
delete – If True, delete duplicate files (keeping the oldest)
move_to – If provided, move duplicate files to this directory instead of deleting
dry_run – If True, only show what would be done without making changes
- OrganiserPro.sorter.get_file_extension(file_path: Path) str[source]
Get the file extension without the dot.
- Parameters:
file_path – Path to the file
- Returns:
- The file extension without the dot, or the full name if no extension,
or empty string for hidden files
- Return type: