← Back to Skills Marketplace
Batch File Renamer
by
LeonardoDpanda
· GitHub ↗
· v1.0.0
424
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install batch-file-renamer
Description
Batch rename files with powerful patterns, regex support, and preview functionality. Use when organizing large numbers of files, standardizing naming convent...
README (SKILL.md)
Batch File Renamer
Powerful batch file renaming with patterns, regex, and preview.
When to Use
- Renaming hundreds of photos from
IMG_001.jpgtoVacation_2025_001.jpg - Adding timestamps to log files
- Cleaning up messy download folders
- Standardizing naming conventions across projects
- Sequential numbering for ordered content
- Removing special characters from filenames
Quick Start
Basic Rename
import os
import re
from datetime import datetime
def batch_rename(directory, pattern, replacement):
"""
Rename files matching pattern
Args:
directory: Path to files
pattern: Regex pattern to match
replacement: Replacement string
"""
renamed = []
for filename in os.listdir(directory):
new_name = re.sub(pattern, replacement, filename)
if new_name != filename:
old_path = os.path.join(directory, filename)
new_path = os.path.join(directory, new_name)
os.rename(old_path, new_path)
renamed.append((filename, new_name))
return renamed
# Example: Add prefix
batch_rename('./photos', r'^(.*)$', r'Vacation_2025_\1')
Sequential Numbering
def number_files(directory, prefix='', digits=3, extension=None):
"""Add sequential numbers to files"""
files = sorted([f for f in os.listdir(directory)
if extension is None or f.endswith(extension)])
renamed = []
for i, filename in enumerate(files, 1):
old_path = os.path.join(directory, filename)
ext = os.path.splitext(filename)[1]
new_name = f"{prefix}{str(i).zfill(digits)}{ext}"
new_path = os.path.join(directory, new_name)
os.rename(old_path, new_path)
renamed.append((filename, new_name))
return renamed
# Usage
number_files('./downloads', prefix='Project_', digits=3)
# Result: Project_001.pdf, Project_002.jpg, ...
Add Timestamps
def add_timestamp(directory, date_format='%Y%m%d'):
"""Add date prefix to files"""
timestamp = datetime.now().strftime(date_format)
for filename in os.listdir(directory):
old_path = os.path.join(directory, filename)
name, ext = os.path.splitext(filename)
new_name = f"{timestamp}_{name}{ext}"
new_path = os.path.join(directory, new_name)
os.rename(old_path, new_path)
# Usage
add_timestamp('./logs')
# Result: 20250303_error.log, 20250303_debug.log
Preview Mode (Safe)
def preview_rename(directory, pattern, replacement):
"""Preview changes without renaming"""
changes = []
for filename in os.listdir(directory):
new_name = re.sub(pattern, replacement, filename)
if new_name != filename:
changes.append(f"{filename} -> {new_name}")
return changes
# Preview first
preview = preview_rename('./files', r'IMG_(\d+)', r'Photo_\1')
for change in preview:
print(change)
Common Patterns
| Pattern | Description | Example |
|---|---|---|
r'^IMG_(\d+)' |
Match IMG_ prefix | IMG_001.jpg |
r'\s+' |
Replace spaces | My File.txt → My_File.txt |
r'[^\w\.]' |
Remove special chars | file@#$%.txt → file.txt |
r'\.jpeg$' |
Change extension | .jpeg → .jpg |
Best Practices
- Always preview first - Use
preview_rename()before actual rename - Backup important files - Renaming is irreversible
- Test on single file - Verify pattern works as expected
- Use regex groups - Capture parts of filename with
(\d+)etc.
Safety Features
def safe_rename(directory, pattern, replacement, dry_run=True):
"""Safe rename with dry-run option"""
changes = []
for filename in os.listdir(directory):
new_name = re.sub(pattern, replacement, filename)
if new_name != filename:
changes.append((filename, new_name))
if dry_run:
print("DRY RUN - Changes that would be made:")
for old, new in changes:
print(f" {old} -> {new}")
return changes
else:
for old, new in changes:
os.rename(
os.path.join(directory, old),
os.path.join(directory, new)
)
return changes
Usage Guidance
This skill is coherent and contains useful local Python examples, but they perform destructive file operations: always run the preview/dry-run first, back up important data, and test patterns on a small sample. Be aware the examples lack collision detection, exception handling, checks for symlinks, and permission/error handling — consider adding safeguards (unique-name checks, try/except around os.rename, handling name collisions) before running on large directories. If you prefer an installable tool, look for a trusted source or packaged implementation rather than copy-pasting unvetted code from an unknown source.
Capability Analysis
Type: OpenClaw Skill
Name: batch-file-renamer
Version: 1.0.0
The skill is classified as suspicious due to its direct file system modification capabilities using `os.rename` and `os.listdir` as demonstrated in the `SKILL.md` file. While these functions are core to a file renaming utility and the skill includes safety features like preview and dry-run modes, the code examples do not implement path sanitization or restriction for the `directory` argument. This means the skill could be directed to operate on arbitrary or sensitive file system paths if the OpenClaw agent or user provides an unvalidated input, posing a potential vulnerability for unintended system modification. There is no evidence of malicious intent such as data exfiltration or backdoors.
Capability Assessment
Purpose & Capability
The name and description (batch rename, regex, preview) match the SKILL.md content. All code examples and guidance relate directly to renaming, numbering, timestamps, and preview/dry-run behavior. No unrelated binaries, credentials, or config paths are requested.
Instruction Scope
The instructions contain concrete Python code that performs local filesystem operations (os.listdir, os.rename) — which is appropriate for a renamer. The SKILL.md explicitly recommends preview and backups and provides a dry-run example. Note: the examples do perform destructive local changes when dry_run=False and do not include collision checks, permission handling, or exception handling; that is a correctness/safety concern but not scope creep.
Install Mechanism
There is no install spec and no code files beyond SKILL.md, so nothing is written to disk by an installer. This low-install surface is proportionate for an instruction-only utility.
Credentials
The skill declares no required environment variables, credentials, or config paths and the instructions do not reference external secrets or unrelated environment state. This is proportionate to the stated functionality.
Persistence & Privilege
The skill is not always-enabled and does not request elevated or persistent system presence. It does not modify other skills or system-wide agent settings.
How to Use
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install batch-file-renamer - After installation, invoke the skill by name or use
/batch-file-renamer - Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release
Metadata
Frequently Asked Questions
What is Batch File Renamer?
Batch rename files with powerful patterns, regex support, and preview functionality. Use when organizing large numbers of files, standardizing naming convent... It is an AI Agent Skill for Claude Code / OpenClaw, with 424 downloads so far.
How do I install Batch File Renamer?
Run "/install batch-file-renamer" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is Batch File Renamer free?
Yes, Batch File Renamer is completely free (open-source). You can download, install and use it at no cost.
Which platforms does Batch File Renamer support?
Batch File Renamer is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created Batch File Renamer?
It is built and maintained by LeonardoDpanda (@leonardodpanda); the current version is v1.0.0.
More Skills