Overview

This Python module provides a FileMover class designed to organize files by moving them into categorized sub-directories within a specified main output folder. It simplifies the process of sorting files based on their processing outcome (e.g., Successful, Skipped, Errors), making it an essential utility for batch processing workflows.


Core Component: FileMover Class

The module is centered around the FileMover class, which handles all file organization and movement logic.

Purpose

The primary role of the FileMover is to take a source file and move it to a specific sub-folder within a pre-defined base output directory. This is particularly useful for scripts that process many files and need to sort them based on the result of the operation.


Initialization

To use the FileMover, you first need to create an instance of it.

from pathlib import Path
from file_operations import FileMover

# Initialize the mover with a path to your desired main output folder.
# This folder will be created automatically if it doesn't exist.
output_manager = FileMover(Path("C:/path/to/main_output"))

Methods

move_file()

This is the main method for moving a file into a categorized sub-directory.


How It Works

The logic of the FileMover is straightforward and robust:

  1. Initialization: An instance of FileMover is created with a path to a base output directory (e.g., ./output). The script ensures this base directory exists.