Easily merge and convert multiple Word documents from a directory (including subfolders) into a single PDF file while preserving formatting, images, and content. This Python script simplifies bulk conversion and document organization.
*For now only DOC and DOCX, you can request more file formats if needed
- Folder Selection: Prompt the user to select a folder containing
.doc
and.docx
files. - File Merging: Combines all Word documents in the folder into a single Word file, ensuring page breaks between documents.
- PDF Conversion: Converts the merged Word file into a single PDF file.
- User-Friendly Interface: Utilizes
Tkinter
andctypes
to provide prompts and notifications. - Error Handling: Logs errors for inaccessible files and handles file conflicts.
- Python: 3.8 or higher.
- Libraries:
docx2pdf
: For converting Word documents to PDF.pywin32
: For interacting with Microsoft Word.tkinter
: For GUI prompts.
-
Clone this repository:
git clone https://github.com/Aloncifras/Folder2PDF.git cd Folder2PDF
-
Install dependencies:
pip install docx2pdf pywin32
-
Ensure Microsoft Word is installed on your system.
-
Run the script:
python Folder2PDF.py
-
Follow the prompts to select a folder containing
.doc
and.docx
files. -
The script will merge all documents in the folder and save the resulting PDF in the same folder with the folder name as the PDF name.
-
Folder Selection:
- The script prompts the user to select a folder.
-
File Processing:
- It iterates through all
.doc
and.docx
files in the folder. - Each document's content is appended to a single Word document with page breaks in between.
- It iterates through all
-
PDF Conversion:
- The merged Word document is converted to a PDF using
docx2pdf
.
- The merged Word document is converted to a PDF using
-
Notifications:
- The user is notified when the process is complete, and the location of the resulting PDF is displayed.
- The script provides logs for each processed file, indicating whether it was successfully merged or if errors occurred.
- The temporary merged document is retained for debugging (can be deleted by uncommenting the cleanup section in the script).
Contributions are welcome! Feel free to open issues or submit pull requests to improve this project.
This project is licensed under the MIT License. See the LICENSE
file for details.