Command-line Python tool for batch analysis, rewriting, summarisation and translation of Markdown and plain-text files using the Gemini API.
The tool accepts a single .txt or .md file, or a folder containing multiple files. It processes each supported file and saves the result to a chosen output directory.
- Processes individual files or folders recursively
- Supports
.txtand.mdinput files - Supports five tasks:
analyzerewritesummarizetranslatecustom
- Produces output in Romanian, English or Hungarian
- Saves one output file per input file
- Preserves Markdown formatting when appropriate
- Supports custom prompts for specialised document transformations
- Allows model, temperature and maximum-output-token configuration
- Supports inline text processing or optional Gemini Files API uploads
- Uses environment variables for API-key handling
- Continues processing remaining files if an individual file fails
- Python 3.10+
- Google Gen AI SDK
- Gemini API
- Gemini Files API
argparse- Batch file processing
- Prompt engineering
Install the dependency:
pip install google-genaiOr create a requirements.txt file containing:
google-genai
Then install it with:
pip install -r requirements.txtSet one of the following environment variables before running the tool.
PowerShell:
$env:GEMINI_API_KEY="your_api_key"Alternatively:
$env:GOOGLE_API_KEY="your_api_key"Never add API keys directly to the script or commit them to GitHub.
The general command format is:
python gemini_text_processor.py INPUT_PATH --task TASK --output-language LANGUAGEAvailable tasks:
analyze
rewrite
summarize
translate
custom
Available output languages:
romanian
english
hungarian
Analyse one text file and save a Romanian report:
python gemini_text_processor.py "input\document.txt" `
--task analyze `
--output-language romanianSummarise all supported files in a folder in English:
python gemini_text_processor.py "input" `
--task summarize `
--output-language english `
--output-dir "output"Translate a Markdown file into Hungarian:
python gemini_text_processor.py "input\document.md" `
--task translate `
--output-language hungarianRewrite documents for clarity and save them with a custom filename suffix:
python gemini_text_processor.py "input" `
--task rewrite `
--output-language english `
--suffix improved-enUse a custom transformation prompt:
python gemini_text_processor.py "input\document.txt" `
--task custom `
--output-language english `
--custom-prompt "Extract the main decisions, deadlines and action items. Return a concise Markdown report."Process files through Gemini Files API instead of placing their content directly in the prompt:
python gemini_text_processor.py "input" `
--task summarize `
--output-language english `
--use-files-apiBy default, output files retain the original extension and receive a suffix based on the selected task and output language.
Example:
meeting-notes.txt
meeting-notes.summarize-english.txt
A custom suffix can be set with --suffix.
--output-dir Output directory, default: output
--model Gemini model, default: gemini-2.5-flash
--temperature Generation temperature, default: 0.3
--max-output-tokens Maximum output tokens, default: 4000
--use-files-api Upload files through Gemini Files API
--suffix Custom output-file suffix
--custom-prompt Required when using --task custom
This repository does not include sample documents, generated outputs or API keys.
When the tool is used, document content is sent to the Gemini API either as inline text or through the Gemini Files API when --use-files-api is selected. Review the applicable API terms and data-handling requirements before processing confidential, personal or sensitive documents.
This project demonstrates practical AI-assisted document processing with a reusable command-line interface, multilingual output control, batch-folder processing, configurable prompts, error handling and structured file output.