A C program that processes ZIP files containing PDFs and generates metadata text files for each PDF. This tool extracts all PDFs from a ZIP file and creates accompanying .txt files containing metadata such as file size and modification date.
- Extracts PDF files from ZIP archives
- Creates a separate directory for extracted files
- Generates metadata files for each PDF containing:
- Original filename
- File size in bytes
- File modification date
- Windows-compatible (built with MinGW-w64)
- Handles both forward and backward slashes in paths
- Includes error handling for file operations
- MinGW-w64 compiler
- libzip library
-
Install MSYS2 if you haven't already:
- Download from: https://www.msys2.org/
- Follow the installation instructions on their website
-
Open MSYS2 MinGW64 terminal and install required packages:
pacman -S mingw-w64-x86_64-gcc
pacman -S mingw-w64-x86_64-libzip
- Clone this repository:
git clone https://github.com/badcircle/zpt.git
cd zpt
- Compile the program:
gcc -o zpt.exe zpt.c -lzip -I/mingw64/include -L/mingw64/lib
- Make sure libzip DLL is in your PATH or copy it to the program directory:
cp /mingw64/bin/libzip*.dll .
zpt.exe <path_to_zip_file>
Example:
zpt.exe documents.zip
This will:
- Create a directory named 'documents' (same as zip file name without extension)
- Extract all PDFs from the ZIP file into this directory
- Create a .txt file for each PDF containing its metadata
The metadata text files will have the same name as their corresponding PDFs but with a .txt extension. Each text file contains a single line with pipe-separated values in this format:
filename.pdf|filesize_in_bytes|modification_date
The program includes error checking for:
- Invalid command-line arguments
- ZIP file opening failures
- Memory allocation errors
- File reading/writing errors
- Invalid file paths
Error messages are printed to stderr with specific details about the failure.
zpt/
├── program.c # Main source code
├── README.md # This file
└── .gitignore # Git ignore file
For development, you might want to add debugging symbols:
gcc -g -o zpt.exe zpt.c -lzip -I/mingw64/include -L/mingw64/lib
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
- libzip library for ZIP file handling
- MinGW-w64 project for Windows compilation support