File Management Automation
Use OpenClaw AI to intelligently organise, rename, deduplicate, and process files based on their content rather than manual rules.
Prerequisites
- OpenClaw v1.0.0+ installed
- API key configured (API Keys Guide)
- Read/write access to the directories you want to manage
- Python 3.9+ (for script-based workflows)
AI-Powered Renaming
Let AI read file contents and generate meaningful names automatically:
# Rename PDFs based on their content
for f in ~/Downloads/*.pdf; do
new_name=$(openclaw run "Read this PDF and suggest a descriptive filename (lowercase, hyphens, no extension)" \
--file "$f")
mv "$f" ~/Documents/"${new_name}.pdf"
echo "Renamed: $f -> ${new_name}.pdf"
done
# Rename screenshots with descriptive names
for img in ~/Desktop/Screenshot*.png; do
desc=$(openclaw run "Describe what is shown in this image in 5 words or fewer, lowercase, hyphen-separated" \
--file "$img")
mv "$img" ~/Pictures/"${desc}.png"
doneOrganise by Content
#!/bin/bash
# sort-documents.sh — categorise files into topic folders
mkdir -p ~/Sorted/{work,personal,finance,legal,other}
for f in ~/Unsorted/*; do
category=$(openclaw run \
"Categorise this document as one of: work, personal, finance, legal, other. Reply with only the category word." \
--file "$f")
mv "$f" ~/Sorted/"${category}/"
echo "Moved $f -> $category/"
doneSemantic Deduplication
Find near-duplicate files that differ only in minor edits or formatting:
# Find semantically similar documents
openclaw run "Compare these files and identify which are near-duplicates (>80% content similarity)." \
--file report-v1.docx \
--file report-v2.docx \
--file report-final.docx \
--file report-FINAL-really.docx
# Output includes a similarity matrix and recommended files to deleteBulk Extract & Transform
# Extract structured data from unstructured files
for invoice in ~/invoices/*.pdf; do
openclaw run "Extract: vendor name, invoice number, date, total amount, due date. Output as JSON." \
--file "$invoice" \
--format json
done | jq -s '.' > invoices-index.json
# Translate a folder of documents
for doc in ~/reports-fr/*.txt; do
openclaw run "Translate this text from French to English, maintaining formatting." \
--file "$doc" \
--output "~/reports-en/$(basename "$doc")"
donePDF and Document Processing
# Extract text from a PDF and summarize
openclaw run "Extract all text, then summarize the key findings in 3 paragraphs" \
--file contract.pdf \
--output contract-summary.txt
# Extract structured data from invoices
for pdf in ~/invoices/*.pdf; do
openclaw run "Extract as JSON: invoice_number, date, vendor, total_amount, line_items" \
--file "$pdf" \
--format json \
--output "~/invoices-json/$(basename $pdf .pdf).json"
done
# Convert PDF tables to CSV
openclaw run "Extract all tables from this report and convert to CSV format" \
--file financial-report.pdf \
--format csv \
--output extracted-tables.csvFile Metadata and Tagging
# Auto-generate tags for images based on filename and context
for img in ~/downloads/*.jpg; do
TAGS=$(openclaw run "Based on this filename, suggest 5 descriptive tags for organizing: $(basename $img)")
echo "$img: $TAGS" >> photo-tags.txt
done
# Generate a manifest file for a folder
find ./project -type f | \
openclaw run "Create a manifest JSON listing each file with: path, description of likely purpose, file type." \
--format json \
--output project-manifest.jsonArchive and Cleanup Automation
#!/usr/bin/env bash
# cleanup.sh — AI-assisted project archiving
PROJECT_DIR="$1"
# Ask AI what's safe to archive
find "$PROJECT_DIR" -mtime +90 -type f | head -50 | \
openclaw run "Review this list of files not accessed in 90+ days. Which are likely safe to archive? Which should be kept active?" \
--output archive-review.txt
echo "Review saved to archive-review.txt. Run manually to proceed."Try It Yourself
Copy and run these commands directly in your terminal to see OpenClaw file automation in action:
1 — Rename all JPG files in a folder by date
# Create a test folder with dummy files
mkdir -p /tmp/openclaw-test && cd /tmp/openclaw-test
touch photo1.jpg photo2.jpg photo3.jpg
# Let OpenClaw rename them by creation date
openclaw run "Rename all .jpg files in /tmp/openclaw-test using the pattern YYYY-MM-DD_originalname.jpg"Expected output: OpenClaw reads each file's modification time, renames them (e.g. 2026-03-12_photo1.jpg), and prints a summary of all changes made.
2 — Sort a mixed downloads folder
openclaw run "Sort all files in ~/Downloads into subfolders by type: Images/, Documents/, Archives/, Code/, Videos/. Do a dry run first and show me the plan."Tip: Always use "dry run first" when running file operations on real data.
3 — Find and delete empty folders
openclaw run "Find all empty directories under /tmp/openclaw-test and list them. Then delete them after confirmation."Always test on non-production data first. Use a copy of your real folder or run with a dry-run flag before applying destructive operations.
What's Next
- Script Execution Automation — generate and run scripts to process your files
- Scheduling — run file management tasks automatically on a schedule
- Task Automation Use Cases — real-world file processing workflows
- AI Pipelines — chain file processing into multi-stage data pipelines
Run dry-runs first
Before bulk renaming or moving, test with --dry-run or redirect output to a log file and review before applying.
See Also