Using Ollama on Windows, Linux, and Mac to Summarize Your Files

Introduction
Summarizing large files manually can be time-consuming, especially when dealing with documents, reports, or research papers. Ollama, a powerful yet lightweight AI model, allows you to generate instant summaries from text files, making content digestion faster and more efficient.
In this guide, we’ll show you how to use Ollama on Windows, Linux, and Mac to automatically summarize files. Whether you prefer a drag-and-drop solution or a simple command-line script (./summary textfile.txt
or summary /folder/path
), this article covers everything you need to know!
Why Use Ollama for File Summarization?
✅ Cross-Platform Compatibility – Runs on Windows, Linux, and Mac with the same setup.
✅ Lightweight & Local Processing – No need for cloud-based APIs; all processing happens on your machine.
✅ Fast & Efficient – Instantly generate summaries without manually reading through long documents.
✅ Simple Automation – Works with a single command or drag-and-drop functionality.
Step 1: Install Ollama on Your System
Before using Ollama, ensure it’s installed on your machine.
Windows (PowerShell)
winget install Ollama
Linux (Ubuntu/Debian-based)
curl -fsSL https://ollama.ai/install.sh | sh
Mac (Homebrew)
brew install ollama
After installation, verify it’s working by running:
ollama run llama2 "Summarize this text: Ollama is a cross-platform AI model for text processing."
Step 2: Create a File Summarization Script
Now, let’s create a script that allows you to drag a file onto an icon or run ./summary file.txt
to generate a summary.
Bash Script for Linux & Mac
Create a new file summary.sh
and add the following:
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: ./summary.sh <filename> or ./summary.sh <folder>"
exit 1
fi
if [ -d "$1" ]; then
for file in "$1"/*.txt; do
echo "Summarizing: $file"
ollama run llama2 "Summarize this: $(cat "$file")" > "$file.summary.txt"
done
else
ollama run llama2 "Summarize this: $(cat "$1")" > "$1.summary.txt"
echo "Summary saved to $1.summary.txt"
fi
Make it executable:
chmod +x summary.sh
Now, you can run:
./summary.sh document.txt
./summary.sh /home/user/documents/
Batch Script for Windows
For Windows, create a file called summary.bat
:
@echo off
if "%~1"=="" (
echo Usage: summary file.txt or summary folder
exit /b
)
if exist "%~1\" (
for %%f in ("%~1\*.txt") do ollama run llama2 "Summarize this: " < "%%f" > "%%f.summary.txt"
) else (
ollama run llama2 "Summarize this: " < "%~1" > "%~1.summary.txt"
echo Summary saved to %~1.summary.txt
)
Now, you can run:
summary.bat document.txt
summary.bat C:\Users\User\Documents
Or, drag and drop a file onto summary.bat
, and it will generate a summary automatically!
Step 3: Testing the Summary Output
Let’s test it on a sample text file:
Example File (document.txt)
Artificial intelligence (AI) has transformed various industries, from healthcare to finance. AI models, such as Ollama, provide fast and efficient text processing capabilities. With AI-driven automation, users can quickly summarize large amounts of information, making data more accessible.
Generated Summary (document.txt.summary.txt)
AI has revolutionized industries by enabling rapid text processing and automation, improving efficiency and accessibility.
Enhancing the Script: Adding Language Support
You can enhance the script by supporting different languages or summary styles.
Adding a Language Option (Bash Example)
Modify summary.sh
to specify the language:
ollama run llama2 "Summarize this in French: $(cat "$1")" > "$1.summary.txt"
Now, it will summarize in French instead of English!
Conclusion
With Ollama, summarizing files is fast, simple, and automated. Whether you prefer drag-and-drop functionality or command-line execution, this approach makes AI-powered text summarization easy on Windows, Linux, and Mac.
🚀 Start using Ollama today and save time summarizing long documents effortlessly!