$0+

File Merge Python Script

I want this!

File Merge Python Script

$0+

Script Description

This script is designed to merge multiple files of the same type located in a source directory into singular merged files for each type. Supported file types include .txt, .docx, .pdf, .xlsx, and .csv.

Files are merged in alphabetical order of their names.

Features:

  1. TXT Files: All .txt files in the source directory are merged into a single merged.txt file, maintaining the content sequence based on filenames.
  2. DOCX Files: All .docx files are combined into a merged.docx file, preserving the original formatting.
  3. PDF Files: All .pdf files are consolidated into a single merged.pdf file.
  4. XLSX Files: All .xlsx files are unified into a merged.xlsx file, keeping the original sheet names and order. The script aims to preserve the formatting as much as possible.
  5. CSV Files: All .csv files, assuming they share the same structure, are combined into a merged.csv file.

If a particular file type has less than two occurrences in the source directory, no merged file will be created for that type in the result directory.

Usage Guide

  1. Prerequisites: Before running the script, ensure you have the required libraries installed. You can install them using:
    pip install python-docx PyPDF2 pandas openpyxl
  2. Directory Structure: Place all the files you wish to merge into a directory named source. Ensure this directory is in the same location as the script.
  3. Running the Script: Run the script using your Python interpreter. For instance, if the script is named merge_files.py, you can execute:
    python merge_files.py
  4. Output: After successful execution, a directory named result will be created (if it doesn't already exist). This directory will contain the merged files.
  5. Note: If there's only one file of a particular type in the source directory (or none), the script will not create a merged file for that type in the result directory.


$
I want this!
30-day money back guarantee
Size
2.99 KB
Copy product URL