The resolve_paths function determines whether a conversion is a single-file operation or a batch operation and calculates the resulting input and output paths.
Behavior:
- If
input_path is a directory, batch is set to True and the output directory is derived from the input directory (or the provided output_path). - If
input_path is a file, batch is set to False. The output path is generated by changing the file extension to .pdf unless an explicit output file is provided.
Returns: A dictionary containing:
batch (bool): True if converting a folder, False for a single file.input (str): The resolved absolute path to the input.output (str): The resolved absolute path to the output file or directory.
from docx2pdf import resolve_paths
# Example of path resolution logic
paths = resolve_paths("my_document.docx", "custom_output.pdf")
# Result: {'batch': False, 'input': '.../my_document.docx', 'output': '.../custom_output.pdf'}